ci: auto-create pull requests for non-main branches
Auto Create PR / create-pr (push) Canceled after 0s
Auto Create PR / create-pr (push) Canceled after 0s
Open a PR to main on every push to another branch, reusing the latest commit title and body as the PR description.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
name: Auto Create PR
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
create-pr:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Create Pull Request
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
CURRENT_BRANCH="${{ github.ref_name }}"
|
||||
|
||||
COMMIT_TITLE=$(git log -1 --pretty=format:%s)
|
||||
COMMIT_BODY=$(git log -1 --pretty=format:%b)
|
||||
|
||||
BODY_CONTENT="${COMMIT_BODY:-Automated PR from $CURRENT_BRANCH to main.}"
|
||||
|
||||
gh pr create \
|
||||
--base main \
|
||||
--head "$CURRENT_BRANCH" \
|
||||
--title "$COMMIT_TITLE" \
|
||||
--body "$BODY_CONTENT" || true
|
||||
Reference in New Issue
Block a user