GitHub Actions create PR and auto merge
Create PR and merge it after all required checks have passed (= auto merge) in GitHub Actions code:yaml
name: sample
on: workflow_dispatch
jobs:
sample:
...
steps:
- uses: actions/checkout@v3
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Create Pull Request
if: ${{ steps.check_diff.outputs.file_count != '0'}}
id: create-pr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ steps.generate-token.outputs.token }}
title: |
Sample
body: |
Sample
commit-message: sample
committer: gitHub actionsbot <github-actionsbot@users.noreply.github.com> author: gitHub actionsbot <github-actionsbot@users.noreply.github.com> signoff: false
branch: ci/sample
base: main
draft: false
- name: merge PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge ${{ steps.create-pr.outputs.pull-request-url }} -s -d --auto