Skip to content

Commit 8ef591c

Browse files
pillo79leonardocavagnis
authored andcommitted
leave_pr_comment: only run if PR_NUM is set
This change fixes the errors that are raised when the workflow is triggered by a push event, which does not have a PR number associated with it. Also, no need to error if the PR number is invalid or if the workflow file is changed in the PR - just issue a warning. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent d4cfe3a commit 8ef591c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

.github/workflows/leave_pr_comment.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ jobs:
3232
- name: Check PR number
3333
id: check-pr
3434
uses: carpentries/actions/check-valid-pr@2e20fd5ee53b691e27455ce7ca3b16ea885140e8 # v0.15.0
35+
if: ${{ env.PR_NUM }}
3536
with:
3637
pr: ${{ env.PR_NUM }}
3738
sha: ${{ github.event.workflow_run.head_sha }}
3839

3940
- name: Validate PR number
40-
if: ${{ steps.check-pr.outputs.VALID != 'true' }}
41+
if: ${{ env.PR_NUM && steps.check-pr.outputs.VALID != 'true' }}
4142
run: |
42-
echo "::error::PR number $PR_NUM validation failed"
43-
exit 1
43+
echo "::warning::PR #$PR_NUM is either invalid or includes changes to workflow"
4444
4545
- name: Update PR comment
46-
if: ${{ steps.check-pr.outputs.VALID == 'true' }}
46+
if: ${{ env.PR_NUM && steps.check-pr.outputs.VALID == 'true' }}
4747
env:
4848
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4949
GH_REPO: ${{ github.repository }}

0 commit comments

Comments
 (0)