diff --git a/.github/workflows/COMMENTS.yml b/.github/workflows/COMMENTS.yml index dd31965..7ea9c44 100644 --- a/.github/workflows/COMMENTS.yml +++ b/.github/workflows/COMMENTS.yml @@ -89,3 +89,31 @@ jobs: issue_number, body: `✅ Version label set to **${label}**` }); + + check-and-label: + # 1. Must be a PR comment (not a plain issue) + # 2. Comment must contain the command (e.g., /merge or trigger-merge) + # 3. User MUST be an OWNER, MEMBER, or COLLABORATOR + if: | + github.event.issue.pull_request != null && + contains(github.event.comment.body, '/merge') && ( + github.event.comment.author_association == 'OWNER' || + github.event.comment.author_association == 'MEMBER' || + github.event.comment.author_association == 'COLLABORATOR' + ) + runs-on: ubuntu-latest + permissions: + pull-requests: write + issues: write + + steps: + - name: Add merge label + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: ['merge'] + }) diff --git a/.github/workflows/VERSION.yml b/.github/workflows/VERSION.yml index e021c50..ee0fc75 100644 --- a/.github/workflows/VERSION.yml +++ b/.github/workflows/VERSION.yml @@ -1,51 +1,59 @@ -name: Automatic version bump +name: Bump and Merge on: - workflow_run: - workflows: ["Pull Request Validation"] - types: [completed] pull_request: - types: [closed] - -permissions: - contents: write + types: [labeled] jobs: - bump: - if: github.event.pull_request.merged == true - + bump-and-merge: + # Only run if both a version label and a merge trigger label are present + if: | + contains(github.event.pull_request.labels.*.name, 'merge') && ( + contains(github.event.pull_request.labels.*.name, 'major') || + contains(github.event.pull_request.labels.*.name, 'feature') || + contains(github.event.pull_request.labels.*.name, 'patch') || + contains(github.event.pull_request.labels.*.name, 'build') + ) runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write steps: - - uses: actions/checkout@v4 - with: - ref: dev - - - uses: actions/setup-python@v5 + - name: Checkout PR Branch + uses: actions/checkout@v4 with: - python-version: "3.12" + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} - - name: Get label + - name: Extract Label id: label run: | echo "LABEL=${{ contains(github.event.pull_request.labels.*.name, 'major') && 'major' || contains(github.event.pull_request.labels.*.name, 'feature') && 'feature' || - contains(github.event.pull_request.labels.*.name, 'patch') && 'patch' || - 'build' + 'patch' }}" >> $GITHUB_OUTPUT - - name: Bump version + - name: Bump Version run: | - python .github/scripts/bump_version.py \ - "${{ steps.label.outputs.LABEL }}" + python .github/scripts/bump_version.py "${{ steps.label.outputs.LABEL }}" - - name: Commit + - name: Commit and Push to PR run: | - git config user.name github-actions - git config user.email github-actions@github.com - + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" git add . - git commit -m "Bump version" + git commit -m "chore(release): bump version before merge [skip ci]" git push - + + - name: Automatically Merge PR + uses: actions/github-script@v7 + with: + script: | + github.rest.pulls.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + merge_method: 'squash' # or 'merge' / 'rebase' + })