docs: mandatory issue templates (AIDM-423) #7886
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: Add milestone to pull requests | |
on: | |
# Only run when a PR is closed | |
pull_request: | |
types: | |
- closed | |
jobs: | |
add_milestone_to_pr: | |
# Only run if the PR was closed due to a merge | |
if: github.event.pull_request.merged == true | |
name: Add milestone to merged pull requests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Include all history and tags | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: '3.8' | |
- name: Get target milestone | |
id: milestones | |
run: | | |
pip install -U pip | |
pip install packaging | |
scripts/get-target-milestone.py | |
- name: Update Pull Request | |
if: steps.milestones.outputs.milestone != null | |
uses: actions/[email protected] | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const title = "${{ steps.milestones.outputs.milestone }}" | |
const milestones = await github.rest.issues.listMilestones({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: "open", | |
}); | |
let milestone = milestones.data.find( (m) => m.title == title ); | |
if (milestone === undefined) { | |
milestone = await github.rest.issues.createMilestone({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: title, | |
}); | |
} | |
await github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.pull_request.number, | |
milestone: milestone.number, | |
}); |