peter-evans/create-pull-request
Commit changes made during a workflow and open (or update) a pull request with them.
What it does
peter-evans/create-pull-request commits any changes a job made to the working tree onto a branch and opens or updates a pull request, which is the standard way to automate dependency bumps, formatting, or generated files.
It only commits changes that already exist in the workspace; make your edits in earlier steps.
Usage
workflow (.yml)
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- run: npm run format # makes the changes
- uses: peter-evans/create-pull-request@v7
with:
commit-message: 'style: apply formatting'
title: 'Automated formatting'
branch: automated/formattingInputs
| Input | Description | Default | Required |
|---|---|---|---|
token | Token to push and open the PR. | GITHUB_TOKEN | No |
commit-message | Commit message for the changes. | - | No |
title | PR title. | - | No |
branch | Branch to create for the PR. | - | No |
base | Base branch to target. | default branch | No |
labels | Labels to add to the PR. | - | No |
Outputs
| Output | Description |
|---|---|
pull-request-number | Number of the created/updated PR. |
pull-request-url | URL of the PR. |
Notes
PRs created with the default GITHUB_TOKEN do not trigger other workflows (to prevent loops). Use a PAT or app token if the PR must run CI.
Enable "Allow GitHub Actions to create and approve pull requests" in repo/org settings.
Common errors
GitHub Actions is not permitted to create or approve pull requestsmeans the org/repo setting is disabled. Enable it.- A created PR that never runs CI is expected with GITHUB_TOKEN; switch to a PAT or app token.
Security and pinning
- Pin to a commit SHA.
- If you use a PAT to trigger downstream workflows, scope it tightly and store it as a secret.
Alternatives and related
Frequently asked questions
Why does my auto-created PR not run any checks?
PRs opened with the default GITHUB_TOKEN intentionally do not trigger workflows. Use a personal access token or a GitHub App token instead.