A pull request bot commits a version bump, a linter fix, or an updated lockfile back to your pull request branch, and your required GitHub Actions workflow never runs. The branch protection rules wait forever for the checks to finish, and the pull request stays blocked.
Here is the exact state of that pull request in the GitHub CLI:
text$ gh pr checks 412
Some checks were not successful
0 passing, 1 pending
PENDING test Required test run pending
If you look at the branch commit log, the bot’s commit is sitting at the tip of the pull request branch. Yet, if you check the Actions tab, no workflow run exists for that commit SHA:
text$ gh run list --commit 84fc7a2
No workflow runs found
Why GitHub Drops Bot Commits
When a job runs inside GitHub Actions, the runner provides an ambient authentication token via secrets.GITHUB_TOKEN or github.token. This token exists so steps can query issues, download build assets, or push changes.
It also comes with an intentional hardcoded limitation: events triggered by GITHUB_TOKEN will not create new workflow runs.
GitHub introduced this restriction to prevent recursive workflow loops. If a workflow triggered on push pushed a commit using GITHUB_TOKEN, that push would trigger another push workflow, consuming billable runner minutes until someone intervened.
When your automation workflow commits back to a branch using GITHUB_TOKEN, the git push succeeds over HTTPS. The branch updates, the pull request interface displays the new commit, but GitHub’s internal webhook pipeline drops the resulting push and pull_request events. Because the check run never starts, the status check remains in a pending state until branch protection stops the merge.
The Reproduction Workflow
Here is a minimal workflow that causes the failure. It attempts to run a formatter on pull requests, commits the changes, and pushes them back:
yaml# .github/workflows/auto-format.yml
name: Auto Format
on:
pull_request:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Format files
run: |
sed -i 's/[ \t]*$//' src/*.sh || true
- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if ! git diff-index --quiet HEAD; then
git commit -m "style: auto-format code"
git push
fi
The push succeeds. Then your required status check workflow, usually defined like this, never executes against that new commit:
yaml# .github/workflows/ci.yml
name: CI
on:
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run test suite
run: ./scripts/test.sh
The Solution: Scoped GitHub App Credentials
Do not use Personal Access Tokens (PATs) for this. Personal tokens tie the automation to a single human user. If that user leaves your organization or rotates their keys, all automation breaks. If that user has broad repo permissions, the PAT likely has broad repo permissions.
The clean solution is a GitHub App. It provides an installation token that acts as an external identity. Commits pushed with an App token trigger downstream workflows normally, just like a human push.
Step 1: Create the GitHub App
- Go to your Organization settings, select Developer settings, then GitHub Apps, and click New GitHub App.
- Set the name to something like
company-pr-automator. - Set the Homepage URL to your repository URL.
- Uncheck Active under Webhook (you do not need to receive webhooks).
- Under Repository permissions, configure:
- Contents: Read and write (to push commits)
- Pull requests: Read and write (optional, useful for branch metadata)
- Click Create GitHub App.
- Note down the App ID displayed on the general page.
- Scroll to the bottom and click Generate a private key. Save the downloaded
.pemfile. - Click Install App in the left sidebar and install it onto your target repository.
Step 2: Store the App Credentials
Convert the private key into a secret. Store both the App ID and the private key in your repository or organization secrets:
bash# Set the App ID
gh secret set APP_ID --body "123456"
# Set the private key from the downloaded pem file
gh secret set APP_PRIVATE_KEY < path/to/app-name.private-key.pem
Step 3: Exchange the Key for a Token in the Workflow
Use the official actions/create-github-app-token action to mint a short-lived token at runtime. Then pass that token directly to actions/checkout.
Here is the updated, working workflow:
yaml# .github/workflows/auto-format.yml
name: Auto Format
on:
pull_request:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Generate App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
ref: ${{ github.head_ref }}
- name: Format files
run: |
sed -i 's/[ \t]*$//' src/*.sh || true
- name: Commit and push changes
run: |
git config user.name "company-pr-automator[bot]"
git config user.email "company-pr-automator[bot]@users.noreply.github.com"
git add -A
if ! git diff-index --quiet HEAD; then
git commit -m "style: auto-format code"
git push origin HEAD:${{ github.head_ref }}
fi
Because actions/checkout receives the App token, it configures local git credentials with that token. When git push runs, GitHub processes the commit as coming from an App rather than GITHUB_TOKEN. The downstream CI workflow triggers immediately.
Verification
To verify the setup works, create a test branch with bad formatting:
bashgit checkout -b test-bot-trigger
echo "echo 'trailing space' " > src/test.sh
git add src/test.sh
git commit -m "test: add file with whitespace"
git push -u origin test-bot-trigger
gh pr create --title "Test automated bot trigger" --body "Checking workflow cascades"
Watch the checks on the PR:
bashgh pr checks --watch
Output should show the format job completing, followed immediately by the required CI run starting on the new commit:
text✓ format Auto Format completed in 12s
* test CI pending...
✓ test CI completed in 44s
All checks were successful
Check the commit history on the PR branch using the CLI:
bashgh pr view --json commits --jq '.commits[].oid'
Output shows two commits: your original commit and the bot commit, both validated:
text7b3e10fa6c04f9821d3f3bf6cce12056345d2e01
f4a210bc931f67891e4e101ab038167cd209bca3
Confirm that the required check belongs to the latest commit:
bashgh run list --commit f4a210bc931f67891e4e101ab038167cd209bca3
textSTATUS NAME WORKFLOW BRANCH EVENT ID ELAPSED AGE
✓ test CI test-bot-trigger pull_request 1192847192 44s 1m
Edge Case 1: Infinite Loops
Now that your bot can trigger workflows, it can trigger itself. If your formatter modifies a file in a way that is non-deterministic (for example, reordering keys randomly or stamping a current timestamp), the bot commits on every push, runs again, modifies the file again, and pushes again.
Prevent this by applying two guardrails.
First, do not trigger the formatting workflow on push. Trigger it on pull_request.
Second, prevent the workflow from processing its own commits by checking the commit author before running the mutation logic:
yaml - name: Check author
id: check-author
run: |
AUTHOR=$(git log -1 --pretty=format:'%an')
if [ "$AUTHOR" = "company-pr-automator[bot]" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Format files
if: steps.check-author.outputs.skip != 'true'
run: |
sed -i 's/[ \t]*$//' src/*.sh || true
Edge Case 2: Outdated Local References on Fast CI
If your CI runs tests concurrently with your auto-formatter, you will hit race conditions. The formatting job commits and pushes. While that happens, the test job might be checking out the parent commit.
If you have branch protection requiring branches to be up to date before merging, the push from the bot will instantly cancel any in-progress runs for the previous SHA.
To prevent wasted compute, tell GitHub Actions to cancel stale runs automatically using concurrency groups keyed to the branch name:
yaml# Add this to both .github/workflows/ci.yml and auto-format.yml
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
The github.head_ref variable is only present on pull_request events. The fallback ${{ github.run_id }} ensures that runs on the default branch (where head_ref is empty) do not accidentally cancel each other.
When the format job pushes its commit, the previous CI run cancels cleanly, and a fresh run begins against the reformatted code.
Edge Case 3: Forked Repositories
GitHub Apps cannot write to forks by default. If a pull request comes from an external contributor via a fork, actions/checkout with your GitHub App token will fail to push back to their branch with a 403 error:
textremote: Permission to fork-user/repo.git denied to company-pr-automator[bot].
fatal: unable to access 'https://github.com/fork-user/repo.git/': The requested URL returned error: 403
If your project relies heavily on public forks, do not push directly to the PR branch. Switch the design: have the formatting check fail and output a patch as an artifact, or require contributors to run pre-commit hooks locally. For internal repositories or private forks within the same organization, ensure the GitHub App is installed across all related repositories.