Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(milestone): add workflow to assign milestone to new PR #934

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/milestone.yml
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 }},
})