Last active
May 20, 2024 18:00
-
-
Save calderwoodra/d43abff0494c9f4493bc7403f815ffa2 to your computer and use it in GitHub Desktop.
Github action which tags major version bumps from dependabot with 'major-version-bump' label. Note: You need to add the 'major-vesrion-bump' label to your repo manually.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tag Major Version Bumps | |
on: | |
pull_request: | |
types: [opened] | |
branches: | |
- main | |
jobs: | |
tag-major-update: | |
runs-on: ubuntu-latest | |
if: github.actor == 'dependabot[bot]' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Tag major version bump | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const title = context.payload.pull_request.title; | |
const versions = title.match(/Bump \S+ from (\d+)\.\d+\.\d+ to (\d+)\.\d+\.\d+/); | |
if (versions && versions[1] !== versions[2]) { | |
console.log(`Major version bump detected: ${versions[1]} -> ${versions[2]}`); | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.number, | |
labels: ['major-version-bump'] | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment