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.
33 lines
756 B
YAML
33 lines
756 B
YAML
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
|