V1.36.0-guance #48
Workflow file for this run
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: Update issues on release | |
on: | |
release: | |
types: [released] | |
workflow_dispatch: | |
inputs: | |
milestone: | |
required: true | |
default: "0.0.0" | |
jobs: | |
update_issues: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get milestone for release | |
id: milestone | |
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const milestone_name = ("${{github.event_name}}" == "workflow_dispatch") ? | |
"${{github.event.inputs.milestone}}" : "${{github.event.release.name}}" | |
const milestones = await github.paginate(github.issues.listMilestones, { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'all' | |
}) | |
return milestones.find( milestone => milestone.title == milestone_name ).number | |
- name: Get issues for milestone | |
id: issues | |
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const issues = await github.paginate(github.issues.listForRepo, { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'all', | |
milestone: ${{steps.milestone.outputs.result}} | |
}) | |
// Pull requests are issues so filter them out | |
return issues.filter( issue => !issue["pull_request"] ).map( issue => issue.number ) | |
- name: Comment and close issues | |
uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # 3.1.0 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
for (let issue_number of ${{ steps.issues.outputs.result }}) { | |
// This can be parallelized better by moving the await but it might trip rate limits | |
await github.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
body: ':robot: This issue has been addressed in the latest release. See full details in the [Release Notes]( ${{ github.event.release.html_url }}).' | |
}) | |
await github.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
state: 'closed' | |
}) | |
} |