Skip to content

Commit 1b1a8d2

Browse files
authored
Better backport error message (#2166)
1 parent ff4d52c commit 1b1a8d2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/workflows/backport.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212
jobs:
1313
backport:
1414
permissions:
15-
contents: write # for Git to git push
15+
contents: write # for git push to PR branch
1616
runs-on: ubuntu-latest
1717
steps:
1818
- run: |
@@ -48,6 +48,15 @@ jobs:
4848
4949
git checkout -b $branch
5050
git cherry-pick $commit
51+
52+
if git diff --name-only HEAD~1 HEAD | grep -q '^\.github/workflows/'; then
53+
echo "::error::This PR contains changes to workflow files (.github/workflows/)."
54+
echo "::error::Workflow files cannot be automatically backported because the standard"
55+
echo "::error::GitHub token doesn't have the required 'workflow' write permission."
56+
echo "::error::Please backport this PR manually."
57+
exit 1
58+
fi
59+
5160
git push --set-upstream origin $branch
5261
gh pr create --title "[$GITHUB_REF_NAME] $title" \
5362
--body "Clean cherry-pick of #$NUMBER to the \`$GITHUB_REF_NAME\` branch." \

0 commit comments

Comments
 (0)