Auto-comment/label issues once on staging

0237b6a872fb0be1ed460a9c57fc2244b2e69bd6

Wolfsblvt <wolfsblvt@gmail.com>

2 files changed, +39 -2Showing whitespace changes
.github/workflows/issues-auto-manager.yml+1 -1
@@ -15,7 +15,7 @@ jobs:
1515 # https://github.com/marketplace/actions/checkout
1616 uses: actions/checkout@v4
1717
1818 - name: Auto-Label Issues (Based on Issue Content)
1919 # Issue Labeler
2020 # https://github.com/marketplace/actions/regex-issue-labeler
2121 uses: github/issue-labeler@v3
.github/workflows/pr-auto-manager.yml+38 -1
@@ -2,7 +2,7 @@ name: 🎯 Pull Request Auto Manager
22
33on:
44 pull_request_target:
55 types: [opened, synchronize, reopened, edited, labeled, unlabeled, closed]
66
77jobs:
88 check-merge-conflicts:
@@ -67,3 +67,40 @@ jobs:
6767 with:
6868 config_file: .github/pr-auto-comments.yml
6969 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