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