|
1 | | -name: Apply kind labels from PR body |
| 1 | +name: Apply kind/area labels and milestone from PR body |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request_target: |
|
34 | 34 | gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "kind/$kind" || \ |
35 | 35 | echo "::warning::Label 'kind/$kind' not found in repository" |
36 | 36 | done |
| 37 | +
|
| 38 | + - name: Sync area labels |
| 39 | + env: |
| 40 | + GH_TOKEN: ${{ github.token }} |
| 41 | + PR_BODY: ${{ github.event.pull_request.body }} |
| 42 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 43 | + REPO: ${{ github.repository }} |
| 44 | + run: | |
| 45 | + # Remove existing area/* labels |
| 46 | + gh pr view "$PR_NUMBER" --repo "$REPO" --json labels \ |
| 47 | + -q '.labels[].name | select(startswith("area/"))' | \ |
| 48 | + while IFS= read -r label; do |
| 49 | + gh pr edit "$PR_NUMBER" --repo "$REPO" --remove-label "$label" |
| 50 | + done |
| 51 | +
|
| 52 | + # Extract /area values from PR body and apply labels |
| 53 | + printf '%s' "$PR_BODY" | tr -d '\r' | grep '^/area ' | \ |
| 54 | + sed 's|^/area ||' | sort -u | \ |
| 55 | + while IFS= read -r area; do |
| 56 | + [ -z "$area" ] && continue |
| 57 | + gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "area/$area" || \ |
| 58 | + echo "::warning::Label 'area/$area' not found in repository" |
| 59 | + done |
| 60 | +
|
| 61 | + - name: Set milestone |
| 62 | + env: |
| 63 | + GH_TOKEN: ${{ github.token }} |
| 64 | + PR_BODY: ${{ github.event.pull_request.body }} |
| 65 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 66 | + REPO: ${{ github.repository }} |
| 67 | + run: | |
| 68 | + # Use the last /milestone directive in the PR body |
| 69 | + milestone=$(printf '%s' "$PR_BODY" | tr -d '\r' | grep '^/milestone ' | \ |
| 70 | + sed 's|^/milestone ||' | tail -n 1) |
| 71 | + [ -z "$milestone" ] && exit 0 |
| 72 | + gh pr edit "$PR_NUMBER" --repo "$REPO" --milestone "$milestone" || \ |
| 73 | + echo "::warning::Milestone '$milestone' not found in repository" |
0 commit comments