Skip to content

Instantly share code, notes, and snippets.

@calderwoodra
Last active May 20, 2024 18:00
Show Gist options
  • Save calderwoodra/d43abff0494c9f4493bc7403f815ffa2 to your computer and use it in GitHub Desktop.
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.
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