Error: refusing to allow a GitHub App to create or update workflow #35410
Replies: 12 comments 20 replies
-
I'm having this issue as well |
Beta Was this translation helpful? Give feedback.
-
You need to grant the workflows permission to your GitHub App.
|
Beta Was this translation helpful? Give feedback.
-
For those who come across this issue here: |
Beta Was this translation helpful? Give feedback.
-
Hey @lktslionel have you found a solution to this?? I've been stuck here for a week now, I tried different things and none seems to work |
Beta Was this translation helpful? Give feedback.
-
Sorry for the misinterpretation, but the following is only for permissions that use tokens generated automatically by GitHub Action. In the workflow file, add: # Set permissions on GITHUB_TOKEN to allow updates to GitHub Actions workflows
permissions:
actions: write In fact, you can also modify the following default parameters: permissions:
actions: read
checks: read
contents: read
deployments: read
discussions: read
issues: read
metadata: read
pages: read
packages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read see:
|
Beta Was this translation helpful? Give feedback.
-
This is pretty high up when searching for the error message, and some of the answers are outdated. As of today (November 2023), I think this is correct:
Something like this: jobs:
changewf:
name: Change a workflow file
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- name: Check out repository
uses: actions/[email protected]
with:
# Fine-grained PAT with contents:write and workflows:write
# scopes
token: ${{ secrets.WORKFLOW_TOKEN }}
- name: Make change to workflow file
GITHUB_TOKEN: ${{ github.token }}
run: |
# Create new branch
git switch -c "feature"
# Edit workflow file
echo "# I am a change!" >> .github/workflows/workflow.yml
git config --global user.name "github-actions"
git config --global user.email \
"41898282+github-actions[bot]@users.noreply.github.com"
git add .github/workflows/workflow.yml
git commit --message "Update workflow"
# This authenticates with WORKFLOW_TOKEN, because it was
# used with the checkout action
git push --set-upstream origin "feature"
# This authenticates with GITHUB_TOKEN, using the scopes
# set in jobs.changewf.permissions
gh pr create --title "Update workflow" --body '' |
Beta Was this translation helpful? Give feedback.
-
For me, it turns out that my CI (in my case prettier) was trying to modify other |
Beta Was this translation helpful? Give feedback.
-
If you are using Github CLI, you need to re-auth with the correct scope -> Your token scopes should be like this |
Beta Was this translation helpful? Give feedback.
-
I am not even modifying a workflow file, yet I still get this. |
Beta Was this translation helpful? Give feedback.
-
I had the same issue and I really do not want to create a PAT for this since I know the default GITHUB_TOKEN can create PRs (so obviously it should be able to create branches, right?!). To solve this, you can checkout the default branches files into your new branch, commit those changes and 🎉 , you're synced and allowed to push! It looks like this: git checkout $COMMIT_SHA
git switch --create $BRANCH_NAME
git checkout origin/main -- ${ROOT_DIR}/.github/workflows
git add ${ROOT_DIR}/.github/workflows
git commit -m "chore: checkout .github/workflows files from main branch"
git push origin $BRANCH_NAME Hope this will help! |
Beta Was this translation helpful? Give feedback.
-
I am working with a github app and I just ran into this issue as well (the commit itself did not modify any workflow file).
The issue turned out to be due to the following line of code:
by removing it everything worked fine. |
Beta Was this translation helpful? Give feedback.
-
This worked for me:
For more info read docs of: https://github.com/actions/create-github-app-token I wanted to sync a fork including tags: name: Sync Fork
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch: # on button click
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
token: ${{ steps.generate-token.outputs.token }}
- name: Merge upstream
run: |
git remote add upstream https://github.com/${FORK-PARENT}
git fetch upstream
git fetch --tags upstream
git merge --no-edit upstream/master
git push
git push --tags |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a weird behaviour on GitHub workflow. I have a workflow that:
And i got the following error:
I don't understand why the workflow think I'm (self) updating the current workflow?
It worked fine before but now it start failing on all my workflows.
Below is the workflow
Any idea?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions