-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(milestone): add workflow to assign milestone to new PR (#934)
- Loading branch information
1 parent
44ca1de
commit 5d9db4c
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Auto Milestone Assign | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened] | ||
|
||
jobs: | ||
assign-milestone: | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Fetch latest milestone | ||
id: fetch-milestone | ||
run: | | ||
LATEST_MILESTONE=$(gh api repos/${{ github.repository }}/milestones --jq '.[0].title') | ||
if [ -z "$LATEST_MILESTONE" ] || [ "$LATEST_MILESTONE" == "null" ]; then | ||
echo "No open milestone found." | ||
exit 1 | ||
fi | ||
echo "latest_milestone=$LATEST_MILESTONE" >> $GITHUB_ENV | ||
- name: Assign milestone to PR | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
github.rest.issues.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.pull_request.number, | ||
milestone: ${{ env.latest_milestone }}, | ||
}) |