Extract workflows for merge conflicts + issue done - Extract merge conflicts check to its own workflow, plus make it run on push - Add issues update as Done or Done staging based on extracted commit messages
| @@ -0,0 +1,39 @@ | ||
| 1 | +name: 🎯 Update Issues on Push | |
| 2 | + | |
| 3 | +on: | |
| 4 | + push: | |
| 5 | + branches: | |
| 6 | + - staging | |
| 7 | + - release | |
| 8 | + | |
| 9 | +jobs: | |
| 10 | + # This runs commits to staging/release, reading the commit messages. Check `pr-auto-manager.yml`:`update-linked-issues` for PR-linked updates. | |
| 11 | + update-linked-issues: | |
| 12 | + name: Update Issues on Push | |
| 13 | + runs-on: ubuntu-latest | |
| 14 | + | |
| 15 | + steps: | |
| 16 | + - name: Checkout Repository | |
| 17 | + # Checkout | |
| 18 | + # https://github.com/marketplace/actions/checkout | |
| 19 | + uses: actions/checkout@v4 | |
| 20 | + | |
| 21 | + - name: Extract Linked Issues from Commit Message | |
| 22 | + id: extract_issues | |
| 23 | + run: | | |
| 24 | + ISSUES=$(git log -1 --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]') | |
| 25 | + echo "issues=$ISSUES" >> $GITHUB_ENV | |
| 26 | + | |
| 27 | + - name: Label Linked Issues | |
| 28 | + id: label_linked_issues | |
| 29 | + env: | |
| 30 | + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} | |
| 31 | + run: | | |
| 32 | + for ISSUE in $(echo $issues | jq -r '.[]'); do | |
| 33 | + echo "Updating issue #$ISSUE" | |
| 34 | + if [ "${{ github.ref }}" == "refs/heads/staging" ]; then | |
| 35 | + gh issue edit $ISSUE -R ${{ github.repository }} --add-label "✅ Done (staging)" | |
| 36 | + elif [ "${{ github.ref }}" == "refs/heads/release" ]; then | |
| 37 | + gh issue edit $ISSUE -R ${{ github.repository }} --add-label "✅ Done" | |
| 38 | + fi | |
| 39 | + done | |
| @@ -7,21 +7,6 @@ on: | ||
| 7 | 7 | types: [created] |
| 8 | 8 | |
| 9 | 9 | jobs: |
| 10 | - check-merge-conflicts: | |
| 11 | - name: Check Merge Conflicts | |
| 12 | - runs-on: ubuntu-latest | |
| 13 | - | |
| 14 | - steps: | |
| 15 | - - name: Check Merge Conflicts | |
| 16 | - # Label Conflicting Pull Requests | |
| 17 | - # https://github.com/marketplace/actions/label-conflicting-pull-requests | |
| 18 | - uses: eps1lon/actions-label-merge-conflict@v3 | |
| 19 | - with: | |
| 20 | - dirtyLabel: '🚫 Merge Conflicts' | |
| 21 | - repoToken: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} | |
| 22 | - commentOnDirty: > | |
| 23 | - ⚠️ This PR has conflicts that need to be resolved before it can be merged. | |
| 24 | - | |
| 25 | 10 | label-by-size: |
| 26 | 11 | name: Apply Label for PR Size |
| 27 | 12 | runs-on: ubuntu-latest |
| @@ -95,8 +80,10 @@ jobs: | ||
| 95 | 80 | |
| 96 | 81 | check-merge-blocking-labels: |
| 97 | 82 | name: Check Merge Blocking Labels |
| 98 | 83 | needs: [checklabel-mergeby-conflictsbranches, label-by-branchesfiles] |
| 99 | 84 | runs-on: ubuntu-latest |
| 85 | + # Run, even if the previous jobs were skipped/failed | |
| 86 | + if: always() | |
| 100 | 87 | |
| 101 | 88 | steps: |
| 102 | 89 | - name: Check Merge Blocking |
| @@ -108,7 +95,6 @@ jobs: | ||
| 108 | 95 | script: | |
| 109 | 96 | const prLabels = context.payload.pull_request.labels.map(label => label.name); |
| 110 | 97 | const blockingLabels = [ |
| 111 | - "🚫 Merge Conflicts", | |
| 112 | 98 | "⛔ Don't Merge", |
| 113 | 99 | "🔨 Needs Work", |
| 114 | 100 | "🔬 Needs Testing", |
| @@ -138,8 +124,10 @@ jobs: | ||
| 138 | 124 | |
| 139 | 125 | write-auto-comments: |
| 140 | 126 | name: Post PR Comments Based on Labels |
| 141 | 127 | needs: [check-merge-conflicts, label-by-size, label-by-branches, label-by-files, remove-stale-label] |
| 142 | 128 | runs-on: ubuntu-latest |
| 129 | + # Run, even if the previous jobs were skipped/failed | |
| 130 | + if: always() | |
| 143 | 131 | |
| 144 | 132 | steps: |
| 145 | 133 | - name: Checkout Repository |
| @@ -155,13 +143,14 @@ jobs: | ||
| 155 | 143 | config_file: .github/pr-auto-comments.yml |
| 156 | 144 | github_token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 157 | 145 | |
| 146 | + # This runs on merged PRs to staging, reading the PR body and directly linked issues. Check `issues-updates-on-merge.yml`:`update-linked-issues` for commit-based updates. | |
| 158 | 147 | update-linked-issues: |
| 159 | 148 | name: Update Issues on Staging Merge |
| 160 | 149 | runs-on: ubuntu-latest |
| 161 | 150 | if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging' |
| 162 | 151 | |
| 163 | 152 | steps: |
| 164 | 153 | - name: Extract Linked Issues From PR Description |
| 165 | 154 | id: extract_issues |
| 166 | 155 | run: | |
| 167 | 156 | 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]') |
| @@ -0,0 +1,24 @@ | ||
| 1 | +name: 🎯 Push Handler | |
| 2 | + | |
| 3 | +on: | |
| 4 | + # So that PRs touching the same files as the push are updated | |
| 5 | + push: | |
| 6 | + # So that the `dirtyLabel` is removed if conflicts are resolved | |
| 7 | + pull_request_target: | |
| 8 | + types: [synchronize] | |
| 9 | + | |
| 10 | +jobs: | |
| 11 | + check-merge-conflicts: | |
| 12 | + name: Check Merge Conflicts | |
| 13 | + runs-on: ubuntu-latest | |
| 14 | + | |
| 15 | + steps: | |
| 16 | + - name: Check Merge Conflicts | |
| 17 | + # Label Conflicting Pull Requests | |
| 18 | + # https://github.com/marketplace/actions/label-conflicting-pull-requests | |
| 19 | + uses: eps1lon/actions-label-merge-conflict@v3 | |
| 20 | + with: | |
| 21 | + dirtyLabel: '🚫 Merge Conflicts' | |
| 22 | + repoToken: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} | |
| 23 | + commentOnDirty: > | |
| 24 | + ⚠️ This PR has conflicts that need to be resolved before it can be merged. | |