Skip to content

Commit 31a334c

Browse files
committed
Use a PAT for the github api calls
The action's token ${{ secrets.GITHUB_TOKEN }} is not allowed to write a comment on the PR or similar, if the PR's source branch is on a fork of the base branch's repo. So we need to use a personal access token instead.
1 parent a51ee27 commit 31a334c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

.github/workflows/fuzzy-ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ env:
3333
GH_API_COMMENTS: ${{ github.event.pull_request.comments_url }}
3434
GH_API_LABELS: ${{ github.event.pull_request.issue_url }}/labels
3535
GH_API_ARTIFACTS: ${{ github.event.pull_request.base.repo.url }}/actions/artifacts
36-
TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
TOKEN: ${{ secrets.MERLINOINS_PAT }}
3737

3838
# URL short-hands
3939
ACTIONS_RUNS_ENDPOINT: ${{ github.event.repository.html_url }}/actions/runs
@@ -293,8 +293,6 @@ jobs:
293293
name: Evaluate diffs
294294
runs-on: ubuntu-22.04
295295
needs: diff
296-
permissions:
297-
pull-requests: write
298296
env:
299297
earlier_diff_was_approved: ${{ contains(github.event.pull_request.labels.*.name, 'fuzzy-diff-looks-good') }}
300298
current_diff_exists: ${{ needs.diff.outputs.diff_exits }}
@@ -345,6 +343,11 @@ jobs:
345343
Previous sha256: ${{ steps.approved_diff_info.outputs.hash }}\n\
346344
Current sha256: $current_diff_hash"
347345
status=$(curl -sL -w "%{http_code}" -o output.txt -X DELETE -H "Authorization: Bearer $TOKEN" "$GH_API_LABELS/$LABEL_NAME")
346+
if [ "$status" -ne 200 ]; then
347+
echo "Something went wrong trying to remove the $LABEL_NAME label. Please, remove it manually."
348+
cat output.txt
349+
fi
350+
exit 2
348351
fi
349352
else
350353
if $current_diff_exists; then
@@ -383,10 +386,13 @@ jobs:
383386
env:
384387
id: ${{ steps.diff_metadata.outputs.id }}
385388
run: |
386-
# FIXME (?)
387389
if [ -z $id ]; then
388390
printf "You seem to have tried to approve a diff that doesn't exist yet.\nWait for the diff to have been generated and then try again."
389391
status=$(curl -sL -w "%{http_code}" -o output.txt -X DELETE -H "Authorization: Bearer $TOKEN" "$GH_API_LABELS/$LABEL_NAME")
392+
if [ "$status" -ne 200 ]; then
393+
echo "Something went wrong trying to remove the $LABEL_NAME label. Please, remove it manually."
394+
cat output.txt
395+
fi
390396
exit 1
391397
else
392398
echo "Diff has been approved."

0 commit comments

Comments
 (0)