Skip to content

Commit 3c09b7f

Browse files
authored
Guard PR commenting on pull requests (Stirling-Tools#6250)
# Description of Changes Attempt 2 at Stirling-Tools#6249
1 parent 5116e6e commit 3c09b7f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ jobs:
100100
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
101101

102102
- name: Comment on Java formatting failure
103-
if: steps.spotless-check.outcome == 'failure'
103+
# Only post a comment on PRs. github-script's PR helpers need an
104+
# issue/PR number, which doesn't exist on merge_group runs.
105+
if: steps.spotless-check.outcome == 'failure' && github.event_name == 'pull_request'
104106
continue-on-error: true
105107
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
106108
with:
@@ -197,6 +199,9 @@ jobs:
197199
if-no-files-found: warn
198200

199201
- name: Add coverage to PR with spring security ${{ matrix.spring-security }} and JDK ${{ matrix.jdk-version }}
202+
# The action only supports the pull_request event (it posts a PR comment),
203+
# so skip it for merge_group runs and workflow_dispatch.
204+
if: github.event_name == 'pull_request'
200205
id: jacoco
201206
uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 # v1.7.2
202207
with:
@@ -284,7 +289,9 @@ jobs:
284289
run: task frontend:check:all
285290
continue-on-error: true
286291
- name: Comment on frontend check failure
287-
if: steps.frontend-check.outcome == 'failure'
292+
# Only post a comment on PRs. github-script's PR helpers need an
293+
# issue/PR number, which doesn't exist on merge_group runs.
294+
if: steps.frontend-check.outcome == 'failure' && github.event_name == 'pull_request'
288295
continue-on-error: true
289296
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
290297
with:

0 commit comments

Comments
 (0)