Skip to content

Commit 1722dcf

Browse files
committed
ci(workflows): gate release behind dev experience
Trigger Release from successful Developer Experience push runs on main/next. Update Developer Experience to run on push. Guard PR-only comment steps so both pull_request_target and push events work.
1 parent e8e7efe commit 1722dcf

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

.github/workflows/dev-experience.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Developer Experience
22
on:
33
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
- next
48
pull_request_target:
59
types:
610
- opened
@@ -68,7 +72,7 @@ jobs:
6872
- name: Checkout
6973
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7074
with:
71-
ref: refs/pull/${{ github.event.pull_request.number }}/merge
75+
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
7276
- name: Configure IaC plugin cache
7377
run: |
7478
echo 'plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"' > ~/.terraformrc
@@ -110,7 +114,7 @@ jobs:
110114
run: ${{ matrix.cli }} validate -no-color
111115
continue-on-error: true
112116
- name: Find Comment
113-
if: matrix.engine == 'terraform'
117+
if: matrix.engine == 'terraform' && github.event_name == 'pull_request_target'
114118
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4
115119
id: find-comment
116120
with:
@@ -119,7 +123,7 @@ jobs:
119123
body-includes: |
120124
Terraform-Check (version: ${{ steps.terraform-version.outputs.TERRAFORM_VERSION }})
121125
- name: Create or update comment
122-
if: matrix.engine == 'terraform'
126+
if: matrix.engine == 'terraform' && github.event_name == 'pull_request_target'
123127
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
124128
with:
125129
comment-id: ${{ steps.find-comment.outputs.comment-id }}
@@ -183,7 +187,7 @@ jobs:
183187
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
184188
with:
185189
fetch-depth: 0
186-
ref: refs/pull/${{ github.event.pull_request.number }}/merge
190+
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
187191
- name: Setup Node and Yarn Cache
188192
uses: ./.github/actions/setup-node-and-yarn-cache
189193
with:
@@ -202,19 +206,19 @@ jobs:
202206
yarn commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose > commitlint_output.txt
203207
working-directory: ./.github/commitlint
204208
- name: Print commitlint output
205-
if: ${{ always() }}
209+
if: ${{ always() && github.event_name == 'pull_request_target' }}
206210
run: |
207211
echo $(cat ./.github/commitlint/commitlint_output.txt)
208212
- name: Set commitlint output to env
209-
if: ${{ always() }}
213+
if: ${{ always() && github.event_name == 'pull_request_target' }}
210214
run: |
211215
{
212216
echo 'commitlint_output<<EOF'
213217
cat ./.github/commitlint/commitlint_output.txt
214218
echo EOF
215219
} >> "$GITHUB_ENV"
216220
- name: Find Comment
217-
if: ${{ always() }}
221+
if: ${{ always() && github.event_name == 'pull_request_target' }}
218222
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4
219223
id: find-comment
220224
with:
@@ -223,7 +227,7 @@ jobs:
223227
body-includes: |
224228
Commitlint-Check
225229
- name: Create or update commitlint comment on failure
226-
if: ${{ failure() }}
230+
if: ${{ failure() && github.event_name == 'pull_request_target' }}
227231
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
228232
with:
229233
comment-id: ${{ steps.find-comment.outputs.comment-id }}
@@ -242,7 +246,7 @@ jobs:
242246
Please update the commit messages accordingly.
243247
reactions: eyes
244248
- name: Create or update commitlint comment on success
245-
if: ${{ success() }}
249+
if: ${{ success() && github.event_name == 'pull_request_target' }}
246250
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
247251
with:
248252
comment-id: ${{ steps.find-comment.outputs.comment-id }}

.github/workflows/release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
name: Release
22
on:
33
workflow_dispatch:
4-
push:
4+
workflow_run:
5+
workflows:
6+
- Developer Experience
7+
types:
8+
- completed
59
branches:
610
- main
711
- next
812

913
permissions: read-all
1014

1115
concurrency:
12-
group: ${{ github.workflow }}-${{ github.ref }}
16+
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.ref }}
1317
cancel-in-progress: false
1418

1519
jobs:
1620
release:
21+
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') }}
1722
runs-on: ubuntu-latest
1823
steps:
1924
- name: Create GitHub App Token
@@ -26,6 +31,7 @@ jobs:
2631
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2732
with:
2833
persist-credentials: false
34+
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
2935
- name: Semantic Release
3036
uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6.0.0
3137
env:

0 commit comments

Comments
 (0)