Increment milestones on tag #98
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: Increment milestones on tag | |
on: | |
create | |
jobs: | |
increment_milestone: | |
if: github.event.ref_type == 'tag' && contains(github.ref_name,'-RC') == false && github.event.master_branch == 'master' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get milestone title | |
id: milestoneTitle | |
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0 | |
with: | |
result-encoding: string | |
script: | | |
// Our tags are of the form vX.X.X and milestones don't have the "v" | |
return '${{github.event.ref}}'.startsWith('v') ? '${{github.event.ref}}'.substring(1) : '${{github.event.ref}}'; | |
- name: Get milestone for tag | |
id: milestone | |
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const milestones = await github.paginate(github.issues.listMilestones, { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'all' | |
}) | |
const milestone = milestones.find(milestone => milestone.title == '${{steps.milestoneTitle.outputs.result}}') | |
if (milestone) { | |
return milestone.number | |
} else { | |
return null | |
} | |
- name: Close milestone | |
if: fromJSON(steps.milestone.outputs.result) | |
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
await github.issues.updateMilestone({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'closed', | |
milestone_number: ${{steps.milestone.outputs.result}} | |
}) | |
- name: Get next minor version | |
if: fromJSON(steps.milestone.outputs.result) | |
id: semvers | |
uses: WyriHaximus/github-action-next-semvers@33d116a4c239252582a60a1ba8dbba63ad493ffd # 1.1.0 | |
with: | |
version: ${{steps.milestoneTitle.outputs.result}} | |
- name: Create next milestone | |
if: fromJSON(steps.milestone.outputs.result) | |
uses: WyriHaximus/github-action-create-milestone@b86699ba7511fa3b61154ac8675d86b01938fc16 # 1.0.0 | |
with: | |
title: ${{ steps.semvers.outputs.minor }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |