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 @@
1name: 🎯 Update Issues on Push
2
3on:
4 push:
5 branches:
6 - staging
7 - release
8
9jobs:
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:
7 types: [created]7 types: [created]
88
9jobs:9jobs:
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 label-by-size:10 label-by-size:
26 name: Apply Label for PR Size11 name: Apply Label for PR Size
27 runs-on: ubuntu-latest12 runs-on: ubuntu-latest
@@ -95,8 +80,10 @@ jobs:
9580
96 check-merge-blocking-labels:81 check-merge-blocking-labels:
97 name: Check Merge Blocking Labels82 name: Check Merge Blocking Labels
98 needs: [check-merge-conflicts, label-by-branches]83 needs: [label-by-branches, label-by-files]
99 runs-on: ubuntu-latest84 runs-on: ubuntu-latest
85 # Run, even if the previous jobs were skipped/failed
86 if: always()
10087
101 steps:88 steps:
102 - name: Check Merge Blocking89 - name: Check Merge Blocking
@@ -108,7 +95,6 @@ jobs:
108 script: |95 script: |
109 const prLabels = context.payload.pull_request.labels.map(label => label.name);96 const prLabels = context.payload.pull_request.labels.map(label => label.name);
110 const blockingLabels = [97 const blockingLabels = [
111 "🚫 Merge Conflicts",
112 "β›” Don't Merge",98 "β›” Don't Merge",
113 "πŸ”¨ Needs Work",99 "πŸ”¨ Needs Work",
114 "πŸ”¬ Needs Testing",100 "πŸ”¬ Needs Testing",
@@ -138,8 +124,10 @@ jobs:
138124
139 write-auto-comments:125 write-auto-comments:
140 name: Post PR Comments Based on Labels126 name: Post PR Comments Based on Labels
141 needs: [check-merge-conflicts, label-by-size, label-by-branches, label-by-files, remove-stale-label]127 needs: [label-by-size, label-by-branches, label-by-files]
142 runs-on: ubuntu-latest128 runs-on: ubuntu-latest
129 # Run, even if the previous jobs were skipped/failed
130 if: always()
143131
144 steps:132 steps:
145 - name: Checkout Repository133 - name: Checkout Repository
@@ -155,13 +143,14 @@ jobs:
155 config_file: .github/pr-auto-comments.yml143 config_file: .github/pr-auto-comments.yml
156 github_token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}144 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.
158 update-linked-issues:147 update-linked-issues:
159 name: Update Issues on Staging Merge148 name: Update Issues on Staging Merge
160 runs-on: ubuntu-latest149 runs-on: ubuntu-latest
161 if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging'150 if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging'
162151
163 steps:152 steps:
164 - name: Extract Linked Issues153 - name: Extract Linked Issues From PR Description
165 id: extract_issues154 id: extract_issues
166 run: |155 run: |
167 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]')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]')
.github/workflows/pr-check-merge-conflicts.yaml+24 -0
@@ -0,0 +1,24 @@
1name: 🎯 Push Handler
2
3on:
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
10jobs:
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.