From 5ffbaf7b0719f45f44268f65949396fc3f7e170f Mon Sep 17 00:00:00 2001 From: Meliox Date: Sun, 7 Jun 2026 16:55:07 +0200 Subject: [PATCH] fix pr create --- .github/workflows/pr-create.yml | 57 ++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pr-create.yml b/.github/workflows/pr-create.yml index 3019715..de53944 100644 --- a/.github/workflows/pr-create.yml +++ b/.github/workflows/pr-create.yml @@ -1,23 +1,22 @@ -name: Open / Update PR +name: Open / Update Version Bump PR -# Triggered by any push to a non-main branch where src/ files changed. -# Opens a PR to main if one does not exist, or updates its body if it does. +# Triggered by any push to main where src/ files changed. +# This happens when a feature PR is merged to main. +# Creates a dedicated chore/version-bump branch and opens a PR from it. # When creating a new PR it assigns the default "bump:patch" label. # When updating an existing PR the label is NOT changed, preserving any # manual label change (e.g. bump:minor, bump:major) made by a reviewer. -# -# Pre-requisite: create the label once in the repo: -# gh label create "bump:patch" --color "0075ca" --description "Default patch-version bump" +# The bot guard prevents this from firing on changelog commits. on: push: - branches-ignore: + branches: - main paths: - 'src/**' permissions: - contents: read + contents: write pull-requests: write jobs: @@ -29,43 +28,57 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - - name: Collect src/ commits on this branch + - name: Collect src/ commits from merge id: commits run: | - LOG=$(git log "origin/main..HEAD" --oneline -- src/ | head -50) - EOF=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null | base64) + LOG=$(git log "HEAD~1..HEAD" --oneline -- src/ | head -50) + EOF=$(openssl rand -hex 16) echo "log<<$EOF" >> "$GITHUB_OUTPUT" echo "$LOG" >> "$GITHUB_OUTPUT" echo "$EOF" >> "$GITHUB_OUTPUT" - - name: Create or update PR + - name: Create or reset version bump branch + run: | + git checkout -B chore/version-bump + git push origin chore/version-bump --force + + - name: Create or update version bump PR env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: ${{ github.ref_name }} - COMMITS: ${{ steps.commits.outputs.log }} + COMMITS: ${{ steps.commits.outputs.log }} run: | - TITLE="feat: $BRANCH" + BUMP_BRANCH="chore/version-bump" + VERSION=$(grep -m1 '(' debian/changelog | sed 's/.*(\(.*\)).*/\1/') + TITLE="chore: bump pve-mod to v${VERSION}" { - echo "## Changes in \`$BRANCH\`" + echo "## Changes merged to main" echo "" echo "${COMMITS:-No src/ changes detected.}" + echo "" + echo "---" + echo "*Apply a bump:minor or bump:major label before merging if needed.*" + echo "*Default label is bump:patch.*" } > /tmp/pr-body.md EXISTING=$(gh pr list \ - --head "$BRANCH" \ + --head "$BUMP_BRANCH" \ + --base main \ --json number --jq '.[0].number' 2>/dev/null || true) if [[ -n "$EXISTING" ]]; then - gh pr edit "$EXISTING" --body-file /tmp/pr-body.md - echo "Updated PR #$EXISTING body (label unchanged)" + gh pr edit "$EXISTING" \ + --title "$TITLE" \ + --body-file /tmp/pr-body.md + echo "Updated PR #${EXISTING} body and title (label unchanged)" else gh pr create \ --title "$TITLE" \ --body-file /tmp/pr-body.md \ --base main \ - --head "$BRANCH" \ + --head "$BUMP_BRANCH" \ --label "bump:patch" - echo "Opened new PR with label bump:patch" - fi + echo "Opened new version bump PR with label bump:patch" + fi \ No newline at end of file