Skip to content

Refusing to Allow a GitHub App to Update Workflow: Fix

Last updated

refusing to allow a GitHub App to create or update workflow ... without workflows permission means a push tried to add or change a file under .github/workflows, and the token used for the push is not allowed to do that. The built-in GITHUB_TOKEN can never edit workflow files: there is no workflows entry that you can add to its permissions: block. You need a different token.

The exact message

! [remote rejected] main -> main (refusing to allow a GitHub App to create or update workflow `.github/workflows/ci.yml` without `workflows` permission)
error: failed to push some refs to 'https://github.com/my-org/my-repo'

You can also see it from peter-evans/create-pull-request, a sync bot, a template updater or Dependabot-style tooling that updates action versions in workflow files.

Why GitHub blocks it

If a workflow could change workflow files with the token it already has, a compromised job could rewrite the pipeline, add itself more privileges, and persist. GitHub therefore requires an explicit, separate permission for it.

Fix 1: use a personal access token with workflow access

Create a token and store it as a secret:

  1. Classic token: tick the workflow scope (plus repo).
  2. Fine-grained token: grant repository permissions Contents: Read and write and Workflows: Read and write, on the repository you push to.

Use it for checkout, so later pushes use it:

- uses: actions/checkout@v4
  with:
    token: ${{ secrets.WORKFLOW_PAT }}
- run: |
    sed -i 's/actions\/checkout@v3/actions\/checkout@v4/' .github/workflows/*.yml
    git config user.name "ci-bot"
    git config user.email "ci-bot@users.noreply.github.com"
    git commit -am "Bump checkout" && git push

Fix 2: use a GitHub App token (better for teams)

Create a GitHub App with Contents: Read and write and Workflows: Read and write, install it on the repository, and mint a short-lived token in the job:

- uses: actions/create-github-app-token@v1
  id: app
  with:
    app-id: ${{ vars.APP_ID }}
    private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
  with:
    token: ${{ steps.app.outputs.token }}

An app token is not tied to one person's account, expires quickly, and is limited to what you granted. It also lets the push start follow-up workflow runs, which the GITHUB_TOKEN does not.

Fix 3: avoid editing workflow files from CI

If you only need to keep action versions current, let Dependabot do it instead of your own script. See Dependabot setup. If you only want to change non-workflow files, make sure your commit does not include anything under .github/workflows, for example with a precise git add.

Check which token the push uses

If you pass token: to actions/checkout but still hit the error, another step may overwrite the git credentials, or persist-credentials: false is set and a later step authenticates with the default token. Print which user you are pushing as with git remote -v (the URL contains no secret) and check that the token you intended is the one stored.

How to prevent it

  1. Keep the workflow-editing token in its own secret, scoped to the one repository.
  2. Prefer GitHub App tokens, and rotate or expire any personal token.
  3. Limit who can change the workflow that holds this power, with branch protection and CODEOWNERS. See CODEOWNERS and branch protection.
  4. Do not run this kind of workflow on pull requests from forks.

FAQ

Can I add workflows: write to the permissions block?

No. The GITHUB_TOKEN has no such permission. Use a personal access token or a GitHub App token.

Does it affect only pushes to .github/workflows?

Yes. The check is about creating or updating files in that directory.

Is this the same as "Resource not accessible by integration"?

Both are token permission problems, but this one is specific to workflow files. For the general API case see Resource not accessible by integration.

Is a personal access token safe to use in CI?

It is as safe as its scope and storage. Use fine-grained tokens limited to one repository, store them as secrets, and prefer an App token where you can.