Skip to content

Commit

Permalink
Create milestone.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
cubxxw authored Apr 3, 2024
1 parent 864e5fe commit daf5270
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# shamelessly copied from https://github.com/sigstore/cosign/blob/main/.github/workflows/milestone.yaml

name: milestone

on:
pull_request_target:
types: [closed]
branches:
- main

jobs:
milestone:
runs-on: ubuntu-latest

permissions:
actions: none
checks: none
contents: read
deployments: none
issues: write
packages: none
pull-requests: write
repository-projects: none
security-events: none
statuses: none

steps:
- uses: actions/github-script@v7 # v6
with:
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
script: |
if (!context.payload.pull_request.merged) {
console.log('PR was not merged, skipping.');
return;
}
if (!!context.payload.pull_request.milestone) {
console.log('PR has existing milestone, skipping.');
return;
}
milestones = await github.rest.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
sort: 'title',
direction: 'desc'
})
if (milestones.data.length === 0) {
console.log('There are no milestones, skipping.');
return;
}
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
milestone: milestones.data[0].number
});

0 comments on commit daf5270

Please sign in to comment.