Skip to content

Compiler does not auto-infer workflows: write on GitHub App tokens when allowed-files targets .github/workflows/ #25767

@devantler

Description

@devantler

Problem

When a workflow uses a GitHub App for safe-output authentication (safe-outputs.github-app:) and create-pull-request.allowed-files includes .github/workflows/*.lock.yml, the compiler does not auto-infer permission-workflows: write on the minted GitHub App token. The PR creation safe-output job then fails because pushing to .github/workflows/ requires the workflows permission per GitHub Actions' built-in branch protection.

Current Workaround

After every gh aw compile, we run a fragile sed injection to manually add permission-workflows: write to the compiled .lock.yml:

sed -i 's/permission-pull-requests: write/permission-pull-requests: write\n          permission-workflows: write/' \
  .github/workflows/daily-workflow-maintenance.lock.yml

This is fragile: it relies on permission-pull-requests: write being present at a specific position in the compiled output. Any compiler change to output ordering or whitespace breaks it.

Expected Behavior

The compiler should auto-infer workflows: write on the GitHub App token when allowed-files (or protected-files: allowed) includes patterns matching .github/workflows/**.

Alternatively, support an explicit permissions: field within safe-outputs.github-app: so users can declare additional GitHub App token permissions:

safe-outputs:
  github-app:
    app-id: ${{ vars.APP_ID }}
    private-key: ${{ secrets.APP_PRIVATE_KEY }}
    permissions:
      workflows: write
  create-pull-request:
    allowed-files:
      - ".github/workflows/*.lock.yml"

Context

  • gh-aw version: v0.68.1 (latest)
  • Related: Cannot create PR modifying .github/workflows/* due to disallowed workflows:write permission #16163 (closed; suggested using GitHub App or custom token, but the compiler gap for workflows: write auto-inference remains)
  • The auth docs state tokens are "minted with permissions specific to the safe output operations being performed" and list workflows under "GitHub App-Only Permissions", yet the compiler does not include it when the allowed-files pattern would require it
  • The permissions docs list workflows as a GitHub App-only permission, confirming it cannot be granted via GITHUB_TOKEN

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions