-
-
Notifications
You must be signed in to change notification settings - Fork 2
45 lines (38 loc) · 1.66 KB
/
Copy pathfleet-label.yml
File metadata and controls
45 lines (38 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Fleet Label PR
on:
pull_request:
types: [opened, edited, synchronize]
permissions:
pull-requests: write
issues: read
jobs:
label_pr:
runs-on: ubuntu-latest
steps:
- name: Check linked issue and apply label/milestone
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
REPO: ${{ github.repository }}
run: |
# Use GitHub's own closing keyword resolution to find linked issues
ISSUE_NUMBER=$(gh pr view "$PR_URL" --json closingIssuesReferences --jq '.closingIssuesReferences[0].number // empty')
if [ -z "$ISSUE_NUMBER" ]; then
echo "No closing issue reference found on this PR. Exiting."
exit 0
fi
echo "Found linked issue: #$ISSUE_NUMBER"
# Check if the linked issue has the 'fleet' label
HAS_FLEET=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json labels --jq '[.labels[].name] | any(. == "fleet")')
if [ "$HAS_FLEET" = "true" ]; then
echo "Linked issue has 'fleet' label. Applying 'fleet-merge-ready' to PR."
gh pr edit "$PR_URL" --add-label "fleet-merge-ready"
# Check if linked issue has a milestone and copy it
MILESTONE_TITLE=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json milestone --jq '.milestone.title // empty')
if [ -n "$MILESTONE_TITLE" ]; then
echo "Applying milestone '$MILESTONE_TITLE' to PR."
gh pr edit "$PR_URL" --milestone "$MILESTONE_TITLE"
fi
else
echo "Linked issue does not have 'fleet' label. Ignoring."
fi