Auto-comment/label issues once on staging

0237b6a872fb0be1ed460a9c57fc2244b2e69bd6

Wolfsblvt <wolfsblvt@gmail.com>

2 files changed, +39 -2Ignore whitespace
.github/workflows/issues-auto-manager.yml+1 -1
@@ -15,7 +15,7 @@ jobs:
15 # https://github.com/marketplace/actions/checkout15 # https://github.com/marketplace/actions/checkout
16 uses: actions/checkout@v416 uses: actions/checkout@v4
1717
18 - name: Auto-Label Issues18 - name: Auto-Label Issues (Based on Issue Content)
19 # Issue Labeler19 # Issue Labeler
20 # https://github.com/marketplace/actions/regex-issue-labeler20 # https://github.com/marketplace/actions/regex-issue-labeler
21 uses: github/issue-labeler@v321 uses: github/issue-labeler@v3
.github/workflows/pr-auto-manager.yml+38 -1
@@ -2,7 +2,7 @@ name: 🎯 Pull Request Auto Manager
22
3on:3on:
4 pull_request_target:4 pull_request_target:
5 types: [opened, synchronize, reopened, edited, labeled, unlabeled]5 types: [opened, synchronize, reopened, edited, labeled, unlabeled, closed]
66
7jobs:7jobs:
8 check-merge-conflicts:8 check-merge-conflicts:
@@ -67,3 +67,40 @@ jobs:
67 with:67 with:
68 config_file: .github/pr-auto-comments.yml68 config_file: .github/pr-auto-comments.yml
69 github_token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}69 github_token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
70
71 update-linked-issues:
72 name: Update Issues on Staging Merge
73 runs-on: ubuntu-latest
74 if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging'
75
76 steps:
77 - name: Extract Linked Issues
78 id: extract_issues
79 run: |
80 ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -oiE '(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved) #([0-9]+)' | awk '{print $2}' | tr -d '#' | jq -R -s -c 'split("\n")[:-1]')
81 echo "issues=$ISSUES" >> $GITHUB_ENV
82
83 - name: Fetch Directly Linked Issues
84 id: fetch_linked_issues
85 run: |
86 PR_NUMBER=${{ github.event.pull_request.number }}
87 REPO=${{ github.repository }}
88 API_URL="https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/issues"
89 ISSUES=$(curl -s -H "Authorization: token ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}" "$API_URL" | jq -r '.[].number' | jq -R -s -c 'split("\n")[:-1]')
90 echo "linked_issues=$ISSUES" >> $GITHUB_ENV
91
92 - name: Merge Issue Lists
93 id: merge_issues
94 run: |
95 ISSUES=$(jq -c -n --argjson a "$issues" --argjson b "$linked_issues" '$a + $b | unique')
96 echo "final_issues=$ISSUES" >> $GITHUB_ENV
97
98 - name: Comment and Label Issues
99 env:
100 GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
101 run: |
102 for ISSUE in $(echo $final_issues | jq -r '.[]'); do
103 echo "Updating issue #$ISSUE"
104 gh issue edit $ISSUE -R ${{ github.repository }} --add-label "✅ Done (staging)"
105 gh issue comment $ISSUE -R ${{ github.repository }} -b "This issue is now available in the \`staging\` branch for testing. Please verify and let us know any feedback!"
106 done