2021-12-04 19:04:10 +02:00
|
|
|
# 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:
|
2022-08-19 14:08:49 +02:00
|
|
|
- uses: actions/github-script@d50f485531ba88479582bc2da03ff424389af5c1 # v6
|
2021-12-04 19:04:10 +02:00
|
|
|
with:
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:24:11 +02:00
|
|
|
milestones = await github.rest.issues.listMilestones({
|
2021-12-04 19:04:10 +02:00
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
state: 'open',
|
|
|
|
sort: 'due_on',
|
|
|
|
direction: 'asc'
|
|
|
|
})
|
|
|
|
if (milestones.data.length === 0) {
|
|
|
|
console.log('There are no milestones, skipping.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:24:11 +02:00
|
|
|
await github.rest.issues.update({
|
2021-12-04 19:04:10 +02:00
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
issue_number: context.payload.pull_request.number,
|
|
|
|
milestone: milestones.data[0].number
|
|
|
|
});
|