File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change 1919 pr-check :
2020 runs-on : ubuntu-latest
2121 permissions :
22- pull-requests : write
2322 contents : read
2423 steps :
2524 - uses : actions/checkout@v4
6261 run : cargo build --release --manifest-path ci/Cargo.toml -p pr-check
6362
6463 - name : Run pr-check
64+ id : run-check
6565 env :
6666 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6767 GITHUB_REPOSITORY : ${{ github.repository }}
6868 PR_NUMBER : ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || github.event.pull_request.number }}
69+ # For pull_request events (including forks), write the comment to a
70+ # file instead of posting it directly. The fork's GITHUB_TOKEN does
71+ # not have write access to the base repository, so direct posting
72+ # returns 403. The pr-comment workflow picks up this artifact and
73+ # posts the comment with the right permissions.
74+ COMMENT_OUTPUT_FILE : ${{ github.event_name == 'pull_request' && 'pr-check-output/comment.md' || '' }}
6975 run : |
70- ci/target/release/pr-check ${{ steps.changed.outputs.files }}
76+ mkdir -p pr-check-output
77+ echo "$PR_NUMBER" > pr-check-output/pr_number.txt
78+ if ci/target/release/pr-check ${{ steps.changed.outputs.files }}; then
79+ echo "passed" > pr-check-output/result.txt
80+ else
81+ echo "failed" > pr-check-output/result.txt
82+ fi
83+
84+ - name : Upload check results
85+ if : always() && github.event_name == 'pull_request'
86+ uses : actions/upload-artifact@v4
87+ with :
88+ name : pr-check-output
89+ path : pr-check-output/
90+
91+ - name : Fail if checks did not pass
92+ if : always()
93+ run : |
94+ result=$(cat pr-check-output/result.txt 2>/dev/null || echo "failed")
95+ [ "$result" = "passed" ]
You can’t perform that action at this time.
0 commit comments