| 67 | with: | 67 | with: |
| 68 | config_file: .github/pr-auto-comments.yml | 68 | 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 |