From bc5ade5314788d067aae68d9d868c5549602d141 Mon Sep 17 00:00:00 2001 From: xEsiah Date: Mon, 16 Nov 2026 00:54:29 +0100 Subject: [PATCH] ci: auto-create pull requests for non-main branches Open a PR to main on every push to another branch, reusing the latest commit title and body as the PR description. --- .github/workflows/auto-create-pr.yml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/auto-create-pr.yml diff --git a/.github/workflows/auto-create-pr.yml b/.github/workflows/auto-create-pr.yml new file mode 100644 index 0000000..87cadbb --- /dev/null +++ b/.github/workflows/auto-create-pr.yml @@ -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