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

5743972a26bf12bb6f9c6df3f1e8f28bd0522c94

Wolfsblvt <wolfsblvt@gmail.com>

3 files changed, +71 -19Ignore whitespace
.github/workflows/issues-updates-on-merge.yml+39 -0
@@ -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
.github/workflows/pr-auto-manager.yml+8 -19
@@ -7,21 +7,6 @@ on:
77 types: [created]
88
99jobs:
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-
2510 label-by-size:
2611 name: Apply Label for PR Size
2712 runs-on: ubuntu-latest
@@ -95,8 +80,10 @@ jobs:
9580
9681 check-merge-blocking-labels:
9782 name: Check Merge Blocking Labels
9883 needs: [checklabel-mergeby-conflictsbranches, label-by-branchesfiles]
9984 runs-on: ubuntu-latest
85+ # Run, even if the previous jobs were skipped/failed
86+ if: always()
10087
10188 steps:
10289 - name: Check Merge Blocking
@@ -108,7 +95,6 @@ jobs:
10895 script: |
10996 const prLabels = context.payload.pull_request.labels.map(label => label.name);
11097 const blockingLabels = [
111- "🚫 Merge Conflicts",
11298 "⛔ Don't Merge",
11399 "🔨 Needs Work",
114100 "🔬 Needs Testing",
@@ -138,8 +124,10 @@ jobs:
138124
139125 write-auto-comments:
140126 name: Post PR Comments Based on Labels
141127 needs: [check-merge-conflicts, label-by-size, label-by-branches, label-by-files, remove-stale-label]
142128 runs-on: ubuntu-latest
129+ # Run, even if the previous jobs were skipped/failed
130+ if: always()
143131
144132 steps:
145133 - name: Checkout Repository
@@ -155,13 +143,14 @@ jobs:
155143 config_file: .github/pr-auto-comments.yml
156144 github_token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
157145
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.
158147 update-linked-issues:
159148 name: Update Issues on Staging Merge
160149 runs-on: ubuntu-latest
161150 if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging'
162151
163152 steps:
164153 - name: Extract Linked Issues From PR Description
165154 id: extract_issues
166155 run: |
167156 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]')
.github/workflows/pr-check-merge-conflicts.yaml+24 -0
@@ -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.