Conversation
Signed-off-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a GitHub Actions workflow that automatically assigns merged PRs and their linked closed issues to version-based milestones. When a PR is merged to main, the workflow reads the current version from nuget-package.props, creates or finds the corresponding milestone, and assigns both the PR and any issues it closes to that milestone.
Key changes:
- Adds milestone auto-assignment workflow triggered on PR merge to main
- Extracts version from
nuget-package.propsto determine milestone name - Parses PR content to identify and assign linked closed issues to the same milestone
| gh pr edit "$PR_NUMBER" --add-label "$VERSION_LABEL" | ||
| if [ -n "$MILESTONE_NUMBER" ]; then | ||
| echo "Assigning PR #$PR_NUMBER to milestone '$VERSION_MILESTONE' (number: $MILESTONE_NUMBER)" | ||
| if gh api repos/:owner/:repo/issues/$PR_NUMBER --method PATCH --field milestone="$MILESTONE_NUMBER" >/dev/null 2>&1; then |
There was a problem hiding this comment.
The milestone assignment API call passes the milestone number as a string instead of an integer. The GitHub API expects milestone to be an integer (the milestone number) or null. Passing it as a string field may cause the API call to fail silently or behave unexpectedly.
Change line 71 to use --field-number instead of --field:
if gh api repos/:owner/:repo/issues/$PR_NUMBER --method PATCH --field-number milestone="$MILESTONE_NUMBER" >/dev/null 2>&1; then| if gh api repos/:owner/:repo/issues/$PR_NUMBER --method PATCH --field milestone="$MILESTONE_NUMBER" >/dev/null 2>&1; then | |
| if gh api repos/:owner/:repo/issues/$PR_NUMBER --method PATCH --field-number milestone="$MILESTONE_NUMBER" >/dev/null 2>&1; then |
| # Get milestone number and assign issue to milestone | ||
| MILESTONE_NUMBER=$(gh api repos/:owner/:repo/milestones --jq ".[] | select(.title == \"$VERSION_MILESTONE\") | .number" 2>/dev/null || echo "") | ||
| if [ -n "$MILESTONE_NUMBER" ]; then | ||
| if gh api repos/:owner/:repo/issues/$ISSUE_NUMBER --method PATCH --field milestone="$MILESTONE_NUMBER" >/dev/null 2>&1; then |
There was a problem hiding this comment.
The milestone assignment API call for issues passes the milestone number as a string instead of an integer. The GitHub API expects milestone to be an integer (the milestone number) or null. Passing it as a string field may cause the API call to fail silently or behave unexpectedly.
Change line 121 to use --field-number instead of --field:
if gh api repos/:owner/:repo/issues/$ISSUE_NUMBER --method PATCH --field-number milestone="$MILESTONE_NUMBER" >/dev/null 2>&1; then| if gh api repos/:owner/:repo/issues/$ISSUE_NUMBER --method PATCH --field milestone="$MILESTONE_NUMBER" >/dev/null 2>&1; then | |
| if gh api repos/:owner/:repo/issues/$ISSUE_NUMBER --method PATCH --field-number milestone="$MILESTONE_NUMBER" >/dev/null 2>&1; then |
| echo "✅ Auto-versioning completed!" | ||
| echo "- Added PR #$PR_NUMBER to milestone '$VERSION_MILESTONE'" | ||
| echo "- Added any linked closed issues to milestone '$VERSION_MILESTONE'" | ||
| echo "- Milestone '$VERSION_MILESTONE' now tracks all PRs and issues for this version" |
There was a problem hiding this comment.
The summary step indicates that labels have been added, but the workflow actually assigns PRs and issues to milestones, not labels. The message should be updated to accurately reflect the milestone assignment behavior:
echo "✅ Auto-milestone assignment completed!"
echo "- Added PR #$PR_NUMBER to milestone '$VERSION_MILESTONE'"
echo "- Added any linked closed issues to milestone '$VERSION_MILESTONE'"
echo "- Milestone '$VERSION_MILESTONE' now tracks all PRs and issues for this version"| @@ -73,14 +107,25 @@ jobs: | |||
|
|
|||
| # Label each found issue | |||
There was a problem hiding this comment.
The job step name references "labeling" issues, but the workflow assigns issues to milestones. This is inconsistent with the actual functionality.
Change line 108 to:
# Assign each found issue to milestone| # Label each found issue | |
| # Assign each found issue to milestone |
No description provided.