name: PR Version Bump and Merge
on:
issue_comment:
types: [created]
jobs:
version-bump:
name: Bump Version with Commitizen
runs-on: ubuntu-latest
if: |
github.event.issue.pull_request &&
contains(github.event.comment.body, '/approve-version-bump')
permissions:
contents: write
pull-requests: write
steps:
- name: Get PR details
id: pr-details
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
// Get PR details
const pr = await github.rest.pulls.get({
owner,
repo,
pull_number: issue_number
});
return {
head_ref: pr.data.head.ref,
head_sha: pr.data.head.sha
};
result-encoding: string
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ fromJSON(steps.pr-details.outputs.result).head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Add approval comment
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚀 Version bump approved! Processing now...'
})
- name: Bump version and update changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
merge: true
changelog_increment_filename: body.md