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 | types: [created] | 7 | types: [created] |
| 8 | 8 | ||
| 9 | jobs: | 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 | label-by-size: | 10 | label-by-size: |
| 26 | name: Apply Label for PR Size | 11 | name: Apply Label for PR Size |
| 27 | runs-on: ubuntu-latest | 12 | runs-on: ubuntu-latest |
| @@ -95,8 +80,10 @@ jobs: | |||
| 95 | 80 | ||
| 96 | check-merge-blocking-labels: | 81 | check-merge-blocking-labels: |
| 97 | name: Check Merge Blocking Labels | 82 | 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-latest | 84 | runs-on: ubuntu-latest |
| 85 | # Run, even if the previous jobs were skipped/failed | ||
| 86 | if: always() | ||
| 100 | 87 | ||
| 101 | steps: | 88 | steps: |
| 102 | - name: Check Merge Blocking | 89 | - 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: | |||
| 138 | 124 | ||
| 139 | write-auto-comments: | 125 | write-auto-comments: |
| 140 | name: Post PR Comments Based on Labels | 126 | 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-latest | 128 | runs-on: ubuntu-latest |
| 129 | # Run, even if the previous jobs were skipped/failed | ||
| 130 | if: always() | ||
| 143 | 131 | ||
| 144 | steps: | 132 | steps: |
| 145 | - name: Checkout Repository | 133 | - name: Checkout Repository |
| @@ -155,13 +143,14 @@ jobs: | |||
| 155 | config_file: .github/pr-auto-comments.yml | 143 | 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 }} |
| 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 | update-linked-issues: | 147 | update-linked-issues: |
| 159 | name: Update Issues on Staging Merge | 148 | name: Update Issues on Staging Merge |
| 160 | runs-on: ubuntu-latest | 149 | 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' |
| 162 | 151 | ||
| 163 | steps: | 152 | steps: |
| 164 | - name: Extract Linked Issues | 153 | - name: Extract Linked Issues From PR Description |
| 165 | id: extract_issues | 154 | 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]') |
| @@ -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. | ||