11name : Developer Experience
22on :
33 workflow_dispatch :
4+ push :
5+ branches :
6+ - main
7+ - next
48 pull_request_target :
59 types :
610 - opened
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 }}
0 commit comments