Try fix PR size labeling by conditional
| @@ -1,7 +1,8 @@ | ||
| 1 | 1 | name: 🔀 Pull Request Manager |
| 2 | 2 | |
| 3 | 3 | on: |
| 4 | 4 | pull_request_targetworkflow_dispatch: |
| 5 | + pull_request: # TODO: This is for texting, and should not be merged into staging. Staging should use 'pull_request_target' | |
| 5 | 6 | types: [opened, synchronize, reopened, edited, labeled, unlabeled, closed] |
| 6 | 7 | pull_request_review_comment: |
| 7 | 8 | types: [created] |
| @@ -14,14 +15,16 @@ jobs: | ||
| 14 | 15 | label-by-size: |
| 15 | 16 | name: 🏷️ Label PR by Size |
| 16 | 17 | runs-on: ubuntu-latest |
| 18 | + # Only needs to run when code is changed | |
| 19 | + if: github.event.action == 'opened' || github.event.action == 'synchronize' | |
| 17 | 20 | |
| 18 | 21 | steps: |
| 19 | 22 | - name: Label PR Size |
| 20 | 23 | # Pull Request Size Labeler |
| 21 | 24 | # https://github.com/marketplace/actions/pull-request-size-labeler |
| 22 | 25 | uses: codelytv/pr-size-labeler@v1.10.12 |
| 23 | 26 | with: |
| 24 | 27 | GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 25 | 28 | xs_label: '🟩 ⬤○○○○' |
| 26 | 29 | xs_max_size: '20' |
| 27 | 30 | s_label: '🟩 ⬤⬤○○○' |
| @@ -32,7 +35,6 @@ jobs: | ||
| 32 | 35 | l_max_size: '1000' |
| 33 | 36 | xl_label: '🟥 ⬤⬤⬤⬤⬤' |
| 34 | 37 | fail_if_xl: 'false' |
| 35 | - github_api_url: 'https://api.github.com' | |
| 36 | 38 | files_to_ignore: | |
| 37 | 39 | "package-lock.json" |
| 38 | 40 | "public/lib/*" |
| @@ -40,8 +42,8 @@ jobs: | ||
| 40 | 42 | label-by-branches: |
| 41 | 43 | name: 🏷️ Label PR by Branches |
| 42 | 44 | runs-on: ubuntu-latest |
| 43 | 45 | # Only label once when PR is created or brancheswhen arebase branch is changed, to allow manual label removal |
| 44 | 46 | if: github.event.action == 'opened' || (github.event.action == 'synchronize' && (github.event.changes.base || github.event.changes.head)) |
| 45 | 47 | |
| 46 | 48 | steps: |
| 47 | 49 | - name: Checkout Repository |
| @@ -55,11 +57,13 @@ jobs: | ||
| 55 | 57 | uses: actions/labeler@v5.0.0 |
| 56 | 58 | with: |
| 57 | 59 | configuration-path: .github/pr-auto-labels-by-branch.yml |
| 58 | 60 | repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 59 | 61 | |
| 60 | 62 | label-by-files: |
| 61 | 63 | name: 🏷️ Label PR by Files |
| 62 | 64 | runs-on: ubuntu-latest |
| 65 | + # Only needs to run when code is changed | |
| 66 | + if: github.event.action == 'opened' || github.event.action == 'synchronize' | |
| 63 | 67 | |
| 64 | 68 | steps: |
| 65 | 69 | - name: Checkout Repository |
| @@ -73,12 +77,12 @@ jobs: | ||
| 73 | 77 | uses: actions/labeler@v5.0.0 |
| 74 | 78 | with: |
| 75 | 79 | configuration-path: .github/pr-auto-labels-by-files.yml |
| 76 | 80 | repo-token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 77 | 81 | |
| 78 | 82 | remove-stale-label: |
| 79 | 83 | name: 🗑️ Remove Stale Label on Comment |
| 80 | 84 | runs-on: ubuntu-latest |
| 81 | 85 | # Only runs when thison iscomments not done by the github actions bot |
| 82 | 86 | if: github.event_name == 'pull_request_review_comment' && github.actor != 'github-actions[bot]' |
| 83 | 87 | |
| 84 | 88 | steps: |
| @@ -88,7 +92,7 @@ jobs: | ||
| 88 | 92 | uses: actions-cool/issues-helper@v3.6.0 |
| 89 | 93 | with: |
| 90 | 94 | actions: 'remove-labels' |
| 91 | 95 | token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 92 | 96 | issue-number: ${{ github.event.pull_request.number }} |
| 93 | 97 | labels: '⚰️ Stale' |
| 94 | 98 | |
| @@ -161,7 +165,7 @@ jobs: | ||
| 161 | 165 | uses: peaceiris/actions-label-commenter@v1.10.0 |
| 162 | 166 | with: |
| 163 | 167 | config_file: .github/pr-auto-comments.yml |
| 164 | 168 | github_token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 165 | 169 | |
| 166 | 170 | # 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. |
| 167 | 171 | update-linked-issues: |
| @@ -182,7 +186,7 @@ jobs: | ||
| 182 | 186 | PR_NUMBER=${{ github.event.pull_request.number }} |
| 183 | 187 | REPO=${{ github.repository }} |
| 184 | 188 | API_URL="https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/issues" |
| 185 | 189 | ISSUES=$(curl -s -H "Authorization: token ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}" "$API_URL" | jq -r '.[].number' | jq -R -s -c 'split("\n")[:-1]') |
| 186 | 190 | echo "linked_issues=$ISSUES" >> $GITHUB_ENV |
| 187 | 191 | |
| 188 | 192 | - name: Merge Issue Lists |
| @@ -194,7 +198,7 @@ jobs: | ||
| 194 | 198 | - name: Label Linked Issues |
| 195 | 199 | id: label_linked_issues |
| 196 | 200 | env: |
| 197 | 201 | GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 198 | 202 | run: | |
| 199 | 203 | for ISSUE in $(echo $final_issues | jq -r '.[]'); do |
| 200 | 204 | gh issue edit $ISSUE -R ${{ github.repository }} --add-label "✅ Done (staging)" |