| 1 | name: 🔄 Update Issues on Push |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - staging |
| 7 | - release |
| 8 | |
| 9 | permissions: |
| 10 | contents: read |
| 11 | issues: write |
| 12 | |
| 13 | jobs: |
| 14 | # This runs commits to staging/release, reading the commit messages. Check `pr-auto-manager.yml`:`update-linked-issues` for PR-linked updates. |
| 15 | update-linked-issues: |
| 16 | name: 🔗 Mark Linked Issues Done on Push |
| 17 | runs-on: ubuntu-latest |
| 18 | if: always() |
| 19 | |
| 20 | steps: |
| 21 | - name: Mint App Token |
| 22 | id: app |
| 23 | # Create a GitHub App token |
| 24 | # https://github.com/marketplace/actions/create-github-app-token |
| 25 | uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2 |
| 26 | with: |
| 27 | app-id: ${{ vars.ST_BOT_APP_ID }} |
| 28 | private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} |
| 29 | owner: ${{ github.repository_owner }} |
| 30 | |
| 31 | - name: Checkout Repository |
| 32 | # Checkout |
| 33 | # https://github.com/marketplace/actions/checkout |
| 34 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 35 | |
| 36 | - name: Extract Linked Issues from Commit Message |
| 37 | id: extract_issues |
| 38 | run: | |
| 39 | ISSUES=$(git log ${{ github.event.before }}..${{ github.event.after }} --pretty=%B | 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]') |
| 40 | echo "issues=$ISSUES" >> $GITHUB_ENV |
| 41 | |
| 42 | - name: Label Linked Issues |
| 43 | id: label_linked_issues |
| 44 | env: |
| 45 | GH_TOKEN: ${{ steps.app.outputs.token }} |
| 46 | run: | |
| 47 | for ISSUE in $(echo $issues | jq -r '.[]'); do |
| 48 | if [ "${{ github.ref }}" == "refs/heads/staging" ]; then |
| 49 | LABEL="✅ Done (staging)" |
| 50 | gh issue edit $ISSUE -R ${{ github.repository }} --add-label "$LABEL" --remove-label "🧑💻 In Progress" |
| 51 | elif [ "${{ github.ref }}" == "refs/heads/release" ]; then |
| 52 | LABEL="✅ Done" |
| 53 | gh issue edit $ISSUE -R ${{ github.repository }} --add-label "$LABEL" --remove-label "🧑💻 In Progress" |
| 54 | fi |
| 55 | echo "Added label '$LABEL' (and removed '🧑💻 In Progress' if present) in issue #$ISSUE" |
| 56 | done |