Skip to content

Commit d04f1b5

Browse files
authored
ci: handle #148 by skipping auto-merge on workflow changes (workaround for App workflows:write) (#152)
ci: skip auto-merge for PRs touching .github/workflows/ to avoid needing workflows:write on App token (#148) Prevents the GraphQL error when App token tries --auto on workflow-editing PRs (e.g. release.yml changes). See also #148 for granting the perm as preferred long-term fix. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 328eac0 commit d04f1b5

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/auto-approve.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,21 @@ jobs:
4141
client-id: ${{ vars.APP_CLIENT_ID }}
4242
private-key: ${{ secrets.APP_PRIVATE_KEY }}
4343

44+
- name: Check for workflow file changes (to avoid App token needing workflows:write)
45+
id: wf-changes
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
pr="${{ github.event.pull_request.number }}"
50+
if gh pr view "$pr" --json files --jq '.files[].path' | grep -q '^\.github/workflows/'; then
51+
echo "changes=true" >> "$GITHUB_OUTPUT"
52+
echo "PR touches .github/workflows/; will skip auto-merge (App lacks workflows:write)"
53+
else
54+
echo "changes=false" >> "$GITHUB_OUTPUT"
55+
fi
56+
4457
- name: Enable auto-merge
45-
if: github.event.pull_request.user.login != 'patchloom-release[bot]'
58+
if: github.event.pull_request.user.login != 'patchloom-release[bot]' && steps.wf-changes.outputs.changes != 'true'
4659
env:
4760
GH_TOKEN: ${{ steps.app-token.outputs.token }}
4861
run: gh pr merge --auto --squash "${{ github.event.pull_request.number }}" --repo "${{ github.repository }}"

0 commit comments

Comments
 (0)