Workflows Switch all to use app token/app for any PR/issue labeling/commenting action (#4624) * ci: switch workflows to use app token/app id authentication * That wasn't supposed to go in this PR * chore: refactor to local token minting step [Test] * chore: expose token output from setup-app-token action and add PR checkout step * ci: replace checkout and custom app token with create-github-app-token action in PR merge conflict workflow * ci: add test label action to PR conflict check workflow * another test... * I am losing my sanity * can this work now? please? This action adds my debug level? * it needs to run always * let's do it via curl...? * why did it (totally not me) remove the always() again * Sorry I screamed at you, Qwen. Does this work? * refactor: consolidate GitHub App token creation into individual jobs * chore: remove debug label functionality from merge conflict workflow * chore: let's figure out why labeler is not behaving * chore: remove temporary GitHub API token validation check from PR workflow * ci: ensure workflow jobs run regardless of previous job failures by adding if: always()
Signed| @@ -15,8 +15,19 @@ jobs: | ||
| 15 | 15 | label-on-content: |
| 16 | 16 | name: π·οΈ Label Issues by Content |
| 17 | 17 | runs-on: ubuntu-latest |
| 18 | + if: always() | |
| 18 | 19 | |
| 19 | 20 | steps: |
| 21 | + - name: Mint App Token | |
| 22 | + id: app | |
| 23 | + # Create a GitHub App token | |
| 24 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 25 | + uses: actions/create-github-app-token@v2 | |
| 26 | + with: | |
| 27 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 28 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 29 | + owner: ${{ github.repository_owner }} | |
| 30 | + | |
| 20 | 31 | - name: Checkout Repository |
| 21 | 32 | # Checkout |
| 22 | 33 | # https://github.com/marketplace/actions/checkout |
| @@ -32,13 +43,25 @@ jobs: | ||
| 32 | 43 | with: |
| 33 | 44 | configuration-path: .github/issues-auto-labels.yml |
| 34 | 45 | enable-versioned-regex: 0 |
| 35 | 46 | repo-token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 36 | 47 | |
| 37 | 48 | label-on-labels: |
| 38 | 49 | name: π·οΈ Label Issues by Labels |
| 50 | + needs: [label-on-content] | |
| 39 | 51 | runs-on: ubuntu-latest |
| 52 | + if: always() | |
| 40 | 53 | |
| 41 | 54 | steps: |
| 55 | + - name: Mint App Token | |
| 56 | + id: app | |
| 57 | + # Create a GitHub App token | |
| 58 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 59 | + uses: actions/create-github-app-token@v2 | |
| 60 | + with: | |
| 61 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 62 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 63 | + owner: ${{ github.repository_owner }} | |
| 64 | + | |
| 42 | 65 | - name: β Add "π Approved" for relevant labels |
| 43 | 66 | if: contains(fromJSON('["π©βπ» Good First Issue", "π Help Wanted", "πͺ² Confirmed", "β οΈ High Priority", "β Medium Priority", "π€ Low Priority"]'), github.event.label.name) |
| 44 | 67 | # π€ Issues Helper |
| @@ -46,7 +69,7 @@ jobs: | ||
| 46 | 69 | uses: actions-cool/issues-helper@v3.6.0 |
| 47 | 70 | with: |
| 48 | 71 | actions: 'add-labels' |
| 49 | 72 | token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 50 | 73 | labels: 'π Approved' |
| 51 | 74 | |
| 52 | 75 | - name: β Remove progress labels when issue is marked done or stale |
| @@ -56,7 +79,7 @@ jobs: | ||
| 56 | 79 | uses: actions-cool/issues-helper@v3.6.0 |
| 57 | 80 | with: |
| 58 | 81 | actions: 'remove-labels' |
| 59 | 82 | token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 60 | 83 | labels: 'π§βπ» In Progress,π€ Unsure,π€ Under Consideration' |
| 61 | 84 | |
| 62 | 85 | - name: β Remove temporary labels when confirmed labels are added |
| @@ -66,7 +89,7 @@ jobs: | ||
| 66 | 89 | uses: actions-cool/issues-helper@v3.6.0 |
| 67 | 90 | with: |
| 68 | 91 | actions: 'remove-labels' |
| 69 | 92 | token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 70 | 93 | labels: 'π€ Unsure,π€ Under Consideration' |
| 71 | 94 | |
| 72 | 95 | - name: β Remove no bug labels when "πͺ² Confirmed" is added |
| @@ -76,32 +99,54 @@ jobs: | ||
| 76 | 99 | uses: actions-cool/issues-helper@v3.6.0 |
| 77 | 100 | with: |
| 78 | 101 | actions: 'remove-labels' |
| 79 | 102 | token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 80 | 103 | labels: 'βοΈ Not Reproducible,βοΈ Not A Bug' |
| 81 | 104 | |
| 82 | 105 | remove-stale-label: |
| 83 | 106 | name: ποΈ Remove Stale Label on Comment |
| 107 | + needs: [label-on-content, label-on-labels] | |
| 84 | 108 | runs-on: ubuntu-latest |
| 85 | 109 | # Only run this on new comments, to automatically remove the stale label |
| 86 | 110 | if: always() && (github.event_name == 'issue_comment' && github.actor != 'github-actions[bot]') |
| 87 | 111 | |
| 88 | 112 | steps: |
| 113 | + - name: Mint App Token | |
| 114 | + id: app | |
| 115 | + # Create a GitHub App token | |
| 116 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 117 | + uses: actions/create-github-app-token@v2 | |
| 118 | + with: | |
| 119 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 120 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 121 | + owner: ${{ github.repository_owner }} | |
| 122 | + | |
| 89 | 123 | - name: Remove Stale Label |
| 90 | 124 | # π€ Issues Helper |
| 91 | 125 | # https://github.com/marketplace/actions/issues-helper |
| 92 | 126 | uses: actions-cool/issues-helper@v3.6.0 |
| 93 | 127 | with: |
| 94 | 128 | actions: 'remove-labels' |
| 95 | 129 | token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 96 | 130 | issue-number: ${{ github.event.issue.number }} |
| 97 | 131 | labels: 'β°οΈ Stale,πΈοΈ Inactive,π Awaiting User Response,π No Response' |
| 98 | 132 | |
| 99 | 133 | write-auto-comments: |
| 100 | 134 | name: π¬ Post Issue Comments Based on Labels |
| 101 | 135 | needs: [label-on-content, label-on-labels, remove-stale-label] |
| 102 | 136 | runs-on: ubuntu-latest |
| 137 | + if: always() | |
| 103 | 138 | |
| 104 | 139 | steps: |
| 140 | + - name: Mint App Token | |
| 141 | + id: app | |
| 142 | + # Create a GitHub App token | |
| 143 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 144 | + uses: actions/create-github-app-token@v2 | |
| 145 | + with: | |
| 146 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 147 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 148 | + owner: ${{ github.repository_owner }} | |
| 149 | + | |
| 105 | 150 | - name: Checkout Repository |
| 106 | 151 | # Checkout |
| 107 | 152 | # https://github.com/marketplace/actions/checkout |
| @@ -113,4 +158,4 @@ jobs: | ||
| 113 | 158 | uses: peaceiris/actions-label-commenter@v1.10.0 |
| 114 | 159 | with: |
| 115 | 160 | config_file: .github/issues-auto-comments.yml |
| 116 | 161 | github_token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| @@ -15,8 +15,19 @@ jobs: | ||
| 15 | 15 | update-linked-issues: |
| 16 | 16 | name: π Mark Linked Issues Done on Push |
| 17 | 17 | runs-on: ubuntu-latest |
| 18 | + if: always() | |
| 18 | 19 | |
| 19 | 20 | steps: |
| 21 | + - name: Mint App Token | |
| 22 | + id: app | |
| 23 | + # Create a GitHub App token | |
| 24 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 25 | + uses: actions/create-github-app-token@v2 | |
| 26 | + with: | |
| 27 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 28 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 29 | + owner: ${{ github.repository_owner }} | |
| 30 | + | |
| 20 | 31 | - name: Checkout Repository |
| 21 | 32 | # Checkout |
| 22 | 33 | # https://github.com/marketplace/actions/checkout |
| @@ -31,7 +42,7 @@ jobs: | ||
| 31 | 42 | - name: Label Linked Issues |
| 32 | 43 | id: label_linked_issues |
| 33 | 44 | env: |
| 34 | 45 | GH_TOKEN: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 35 | 46 | run: | |
| 36 | 47 | for ISSUE in $(echo $issues | jq -r '.[]'); do |
| 37 | 48 | if [ "${{ github.ref }}" == "refs/heads/staging" ]; then |
| @@ -15,14 +15,25 @@ jobs: | ||
| 15 | 15 | mark-inactivity: |
| 16 | 16 | name: β³ Mark Issues/PRs without Activity |
| 17 | 17 | runs-on: ubuntu-latest |
| 18 | + if: always() | |
| 18 | 19 | |
| 19 | 20 | steps: |
| 21 | + - name: Mint App Token | |
| 22 | + id: app | |
| 23 | + # Create a GitHub App token | |
| 24 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 25 | + uses: actions/create-github-app-token@v2 | |
| 26 | + with: | |
| 27 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 28 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 29 | + owner: ${{ github.repository_owner }} | |
| 30 | + | |
| 20 | 31 | - name: Mark Issues/PRs without Activity |
| 21 | 32 | # Close Stale Issues and PRs |
| 22 | 33 | # https://github.com/marketplace/actions/close-stale-issues |
| 23 | 34 | uses: actions/stale@v9.1.0 |
| 24 | 35 | with: |
| 25 | 36 | repo-token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 26 | 37 | days-before-stale: 183 |
| 27 | 38 | days-before-close: 7 |
| 28 | 39 | operations-per-run: 30 |
| @@ -47,16 +58,27 @@ jobs: | ||
| 47 | 58 | |
| 48 | 59 | await-user-response: |
| 49 | 60 | name: β οΈ Mark Issues/PRs Awaiting User Response |
| 61 | + needs: [mark-inactivity] | |
| 50 | 62 | runs-on: ubuntu-latest |
| 51 | - needs: mark-inactivity | |
| 63 | + if: always() | |
| 52 | 64 | |
| 53 | 65 | steps: |
| 66 | + - name: Mint App Token | |
| 67 | + id: app | |
| 68 | + # Create a GitHub App token | |
| 69 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 70 | + uses: actions/create-github-app-token@v2 | |
| 71 | + with: | |
| 72 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 73 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 74 | + owner: ${{ github.repository_owner }} | |
| 75 | + | |
| 54 | 76 | - name: Mark Issues/PRs Awaiting User Response |
| 55 | 77 | # Close Stale Issues and PRs |
| 56 | 78 | # https://github.com/marketplace/actions/close-stale-issues |
| 57 | 79 | uses: actions/stale@v9.1.0 |
| 58 | 80 | with: |
| 59 | 81 | repo-token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 60 | 82 | days-before-stale: 7 |
| 61 | 83 | days-before-close: 7 |
| 62 | 84 | operations-per-run: 30 |
| @@ -74,16 +96,27 @@ jobs: | ||
| 74 | 96 | |
| 75 | 97 | alternative-exists: |
| 76 | 98 | name: π Mark Issues with Alternative Exists |
| 99 | + needs: [mark-inactivity, await-user-response] | |
| 77 | 100 | runs-on: ubuntu-latest |
| 78 | - needs: await-user-response | |
| 101 | + if: always() | |
| 79 | 102 | |
| 80 | 103 | steps: |
| 104 | + - name: Mint App Token | |
| 105 | + id: app | |
| 106 | + # Create a GitHub App token | |
| 107 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 108 | + uses: actions/create-github-app-token@v2 | |
| 109 | + with: | |
| 110 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 111 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 112 | + owner: ${{ github.repository_owner }} | |
| 113 | + | |
| 81 | 114 | - name: Mark Issues with Alternative Exists |
| 82 | 115 | # Close Stale Issues and PRs |
| 83 | 116 | # https://github.com/marketplace/actions/close-stale-issues |
| 84 | 117 | uses: actions/stale@v9.1.0 |
| 85 | 118 | with: |
| 86 | 119 | repo-token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 87 | 120 | days-before-stale: 7 |
| 88 | 121 | days-before-close: 7 |
| 89 | 122 | operations-per-run: 30 |
| @@ -15,14 +15,25 @@ jobs: | ||
| 15 | 15 | remove-labels: |
| 16 | 16 | name: ποΈ Remove Pending Labels on Close |
| 17 | 17 | runs-on: ubuntu-latest |
| 18 | + if: always() | |
| 18 | 19 | |
| 19 | 20 | steps: |
| 21 | + - name: Mint App Token | |
| 22 | + id: app | |
| 23 | + # Create a GitHub App token | |
| 24 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 25 | + uses: actions/create-github-app-token@v2 | |
| 26 | + with: | |
| 27 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 28 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 29 | + owner: ${{ github.repository_owner }} | |
| 30 | + | |
| 20 | 31 | - name: Remove Pending Labels on Close |
| 21 | 32 | # π€ Issues Helper |
| 22 | 33 | # https://github.com/marketplace/actions/issues-helper |
| 23 | 34 | uses: actions-cool/issues-helper@v3.6.0 |
| 24 | 35 | with: |
| 25 | 36 | actions: remove-labels |
| 26 | 37 | token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 27 | 38 | issue-number: ${{ github.event.issue.number || github.event.pull_request.number }} |
| 28 | 39 | labels: 'π Awaiting User Response,π§βπ» In Progress,π Keep Open,π« Merge Conflicts,π¬ Needs Testing,π¨ Needs Work,β°οΈ Stale,β Waiting For External/Upstream' |
| @@ -15,15 +15,25 @@ jobs: | ||
| 15 | 15 | label-maintainer: |
| 16 | 16 | name: π·οΈ Label if Author is a Repo Maintainer |
| 17 | 17 | runs-on: ubuntu-latest |
| 18 | 18 | if: always() && contains(fromJson('["Cohee1207", "RossAscends", "Wolfsblvt"]'), github.actor) |
| 19 | 19 | |
| 20 | 20 | steps: |
| 21 | + - name: Mint App Token | |
| 22 | + id: app | |
| 23 | + # Create a GitHub App token | |
| 24 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 25 | + uses: actions/create-github-app-token@v2 | |
| 26 | + with: | |
| 27 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 28 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 29 | + owner: ${{ github.repository_owner }} | |
| 30 | + | |
| 21 | 31 | - name: Label if Author is a Repo Maintainer |
| 22 | 32 | # π€ Issues Helper |
| 23 | 33 | # https://github.com/marketplace/actions/issues-helper |
| 24 | 34 | uses: actions-cool/issues-helper@v3.6.0 |
| 25 | 35 | with: |
| 26 | 36 | actions: 'add-labels' |
| 27 | 37 | token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 28 | 38 | issue-number: ${{ github.event.issue.number || github.event.pull_request.number }} |
| 29 | 39 | labels: 'π· Maintainer' |
| @@ -12,30 +12,11 @@ permissions: | ||
| 12 | 12 | pull-requests: write |
| 13 | 13 | |
| 14 | 14 | jobs: |
| 15 | - app-auth: | |
| 16 | - name: π Mint App token | |
| 17 | - runs-on: ubuntu-latest | |
| 18 | - if: always() | |
| 19 | - | |
| 20 | - outputs: | |
| 21 | - app_token: ${{ steps.app.outputs.token }} | |
| 22 | - | |
| 23 | - steps: | |
| 24 | - - name: Create GitHub App Token | |
| 25 | - # Create a GitHub App token | |
| 26 | - # https://github.com/marketplace/actions/create-github-app-token | |
| 27 | - uses: actions/create-github-app-token@v2 | |
| 28 | - id: app | |
| 29 | - with: | |
| 30 | - app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 31 | - private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 32 | - owner: ${{ github.repository_owner }} | |
| 33 | - | |
| 34 | 15 | run-eslint: |
| 35 | 16 | name: β Check ESLint on PR |
| 36 | 17 | runs-on: ubuntu-latest |
| 37 | 18 | # Only needs to run when code is changed |
| 38 | 19 | if: always() && (github.event.action == 'opened' || github.event.action == 'synchronize') |
| 39 | 20 | |
| 40 | 21 | # Override permissions, linter likely needs write access to issues |
| 41 | 22 | permissions: |
| @@ -67,7 +48,7 @@ jobs: | ||
| 67 | 48 | # https://github.com/marketplace/actions/action-eslint |
| 68 | 49 | uses: sibiraj-s/action-eslint@v3.0.1 |
| 69 | 50 | with: |
| 70 | 51 | token: ${{ secrets.GITHUB_TOKEN }} # ESLint can run with the original permissions |
| 71 | 52 | eslint-args: '--ignore-path=.gitignore --quiet' |
| 72 | 53 | extensions: 'js' |
| 73 | 54 | annotations: true |
| @@ -78,7 +59,7 @@ jobs: | ||
| 78 | 59 | label-by-size: |
| 79 | 60 | name: π·οΈ Label PR by Size |
| 80 | 61 | # This job should run after all others, to prevent possible concurrency issues |
| 81 | 62 | needs: [app-auth, label-by-branches, label-by-files, remove-stale-label, check-merge-blocking-labels, write-auto-comments] |
| 82 | 63 | runs-on: ubuntu-latest |
| 83 | 64 | # Only needs to run when code is changed |
| 84 | 65 | if: always() && (github.event.action == 'opened' || github.event.action == 'synchronize') |
| @@ -90,12 +71,22 @@ jobs: | ||
| 90 | 71 | pull-requests: write |
| 91 | 72 | |
| 92 | 73 | steps: |
| 74 | + - name: Mint App Token | |
| 75 | + id: app | |
| 76 | + # Create a GitHub App token | |
| 77 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 78 | + uses: actions/create-github-app-token@v2 | |
| 79 | + with: | |
| 80 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 81 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 82 | + owner: ${{ github.repository_owner }} | |
| 83 | + | |
| 93 | 84 | - name: Label PR Size |
| 94 | 85 | # Pull Request Size Labeler |
| 95 | 86 | # https://github.com/marketplace/actions/pull-request-size-labeler |
| 96 | 87 | uses: codelytv/pr-size-labeler@v1.10.2 |
| 97 | 88 | with: |
| 98 | 89 | GITHUB_TOKEN: ${{ needssteps.app-auth.outputs.app_tokentoken }} |
| 99 | 90 | xs_label: 'π© ⬀ββββ' |
| 100 | 91 | xs_max_size: '20' |
| 101 | 92 | s_label: 'π© ⬀⬀βββ' |
| @@ -112,12 +103,21 @@ jobs: | ||
| 112 | 103 | |
| 113 | 104 | label-by-branches: |
| 114 | 105 | name: π·οΈ Label PR by Branches |
| 115 | - needs: [app-auth] | |
| 116 | 106 | runs-on: ubuntu-latest |
| 117 | 107 | # Only label once when PR is created or when base branch is changed, to allow manual label removal |
| 118 | 108 | if: always() && (github.event.action == 'opened' || (github.event.action == 'synchronize' && github.event.changes.base)) |
| 119 | 109 | |
| 120 | 110 | steps: |
| 111 | + - name: Mint App Token | |
| 112 | + id: app | |
| 113 | + # Create a GitHub App token | |
| 114 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 115 | + uses: actions/create-github-app-token@v2 | |
| 116 | + with: | |
| 117 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 118 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 119 | + owner: ${{ github.repository_owner }} | |
| 120 | + | |
| 121 | 121 | - name: Checkout Repository |
| 122 | 122 | # Checkout |
| 123 | 123 | # https://github.com/marketplace/actions/checkout |
| @@ -129,16 +129,26 @@ jobs: | ||
| 129 | 129 | uses: actions/labeler@v5.0.0 |
| 130 | 130 | with: |
| 131 | 131 | configuration-path: .github/pr-auto-labels-by-branch.yml |
| 132 | 132 | repo-token: ${{ needssteps.app-auth.outputs.app_tokentoken }} |
| 133 | 133 | |
| 134 | 134 | label-by-files: |
| 135 | 135 | name: π·οΈ Label PR by Files |
| 136 | 136 | needs: [applabel-authby-branches] |
| 137 | 137 | runs-on: ubuntu-latest |
| 138 | 138 | # Only needs to run when code is changed |
| 139 | 139 | if: always() && (github.event.action == 'opened' || github.event.action == 'synchronize') |
| 140 | 140 | |
| 141 | 141 | steps: |
| 142 | + - name: Mint App Token | |
| 143 | + id: app | |
| 144 | + # Create a GitHub App token | |
| 145 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 146 | + uses: actions/create-github-app-token@v2 | |
| 147 | + with: | |
| 148 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 149 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 150 | + owner: ${{ github.repository_owner }} | |
| 151 | + | |
| 142 | 152 | - name: Checkout Repository |
| 143 | 153 | # Checkout |
| 144 | 154 | # https://github.com/marketplace/actions/checkout |
| @@ -148,15 +158,18 @@ jobs: | ||
| 148 | 158 | # Pull Request Labeler |
| 149 | 159 | # https://github.com/marketplace/actions/labeler |
| 150 | 160 | uses: actions/labeler@v5.0.0 |
| 161 | + env: | |
| 162 | + GITHUB_TOKEN: ${{ steps.app.outputs.token }} # labeler action needs some handholding | |
| 151 | 163 | with: |
| 152 | 164 | configuration-path: .github/pr-auto-labels-by-files.yml |
| 153 | 165 | repo-token: ${{ needssteps.app-auth.outputs.app_tokentoken }} |
| 154 | 166 | |
| 155 | 167 | remove-stale-label: |
| 156 | 168 | name: ποΈ Remove Stale Label on Comment |
| 169 | + needs: [label-by-branches, label-by-files] | |
| 157 | 170 | runs-on: ubuntu-latest |
| 158 | 171 | # Only runs on comments not done by the github actions bot |
| 159 | 172 | if: always() && (github.event_name == 'pull_request_review_comment' && github.actor != 'github-actions[bot]') |
| 160 | 173 | |
| 161 | 174 | # Override permissions, issue labeler needs issues write access |
| 162 | 175 | permissions: |
| @@ -165,19 +178,29 @@ jobs: | ||
| 165 | 178 | pull-requests: write |
| 166 | 179 | |
| 167 | 180 | steps: |
| 181 | + - name: Mint App Token | |
| 182 | + id: app | |
| 183 | + # Create a GitHub App token | |
| 184 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 185 | + uses: actions/create-github-app-token@v2 | |
| 186 | + with: | |
| 187 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 188 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 189 | + owner: ${{ github.repository_owner }} | |
| 190 | + | |
| 168 | 191 | - name: Remove Stale Label |
| 169 | 192 | # π€ Issues Helper |
| 170 | 193 | # https://github.com/marketplace/actions/issues-helper |
| 171 | 194 | uses: actions-cool/issues-helper@v3.6.0 |
| 172 | 195 | with: |
| 173 | 196 | actions: 'remove-labels' |
| 174 | 197 | token: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 175 | 198 | issue-number: ${{ github.event.pull_request.number }} |
| 176 | 199 | labels: 'β°οΈ Stale' |
| 177 | 200 | |
| 178 | 201 | check-merge-blocking-labels: |
| 179 | 202 | name: π« Check Merge Blocking Labels |
| 180 | 203 | needs: [label-by-branches, label-by-files, remove-stale-label] |
| 181 | 204 | runs-on: ubuntu-latest |
| 182 | 205 | # Run, even if the previous jobs were skipped/failed |
| 183 | 206 | if: always() |
| @@ -227,12 +250,22 @@ jobs: | ||
| 227 | 250 | |
| 228 | 251 | write-auto-comments: |
| 229 | 252 | name: π¬ Post PR Comments Based on Labels |
| 230 | 253 | needs: [label-by-branches, label-by-files, remove-stale-label, check-merge-blocking-labels] |
| 231 | 254 | runs-on: ubuntu-latest |
| 232 | 255 | # Run, even if the previous jobs were skipped/failed |
| 233 | 256 | if: always() |
| 234 | 257 | |
| 235 | 258 | steps: |
| 259 | + - name: Mint App Token | |
| 260 | + id: app | |
| 261 | + # Create a GitHub App token | |
| 262 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 263 | + uses: actions/create-github-app-token@v2 | |
| 264 | + with: | |
| 265 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 266 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 267 | + owner: ${{ github.repository_owner }} | |
| 268 | + | |
| 236 | 269 | - name: Checkout Repository |
| 237 | 270 | # Checkout |
| 238 | 271 | # https://github.com/marketplace/actions/checkout |
| @@ -244,13 +277,13 @@ jobs: | ||
| 244 | 277 | uses: peaceiris/actions-label-commenter@v1.10.0 |
| 245 | 278 | with: |
| 246 | 279 | config_file: .github/pr-auto-comments.yml |
| 247 | 280 | github_token: ${{ secretssteps.GITHUB_TOKENapp.outputs.token }} |
| 248 | 281 | |
| 249 | 282 | # 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. |
| 250 | 283 | update-linked-issues: |
| 251 | 284 | name: π Mark Linked Issues Done on Staging Merge |
| 252 | 285 | runs-on: ubuntu-latest |
| 253 | 286 | if: always() && (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging') |
| 254 | 287 | |
| 255 | 288 | # Override permissions, We need to be able to write to issues |
| 256 | 289 | permissions: |
| @@ -259,6 +292,16 @@ jobs: | ||
| 259 | 292 | pull-requests: write |
| 260 | 293 | |
| 261 | 294 | steps: |
| 295 | + - name: Mint App Token | |
| 296 | + id: app | |
| 297 | + # Create a GitHub App token | |
| 298 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 299 | + uses: actions/create-github-app-token@v2 | |
| 300 | + with: | |
| 301 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 302 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 303 | + owner: ${{ github.repository_owner }} | |
| 304 | + | |
| 262 | 305 | - name: Extract Linked Issues From PR Description |
| 263 | 306 | id: extract_issues |
| 264 | 307 | run: | |
| @@ -271,7 +314,7 @@ jobs: | ||
| 271 | 314 | PR_NUMBER=${{ github.event.pull_request.number }} |
| 272 | 315 | REPO=${{ github.repository }} |
| 273 | 316 | API_URL="https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/issues" |
| 274 | 317 | ISSUES=$(curl -s -H "Authorization: token ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }}" "$API_URL" | jq -r '.[].number' | jq -R -s -c 'split("\n")[:-1]') |
| 275 | 318 | echo "linked_issues=$ISSUES" >> $GITHUB_ENV |
| 276 | 319 | |
| 277 | 320 | - name: Merge Issue Lists |
| @@ -283,7 +326,7 @@ jobs: | ||
| 283 | 326 | - name: Label Linked Issues |
| 284 | 327 | id: label_linked_issues |
| 285 | 328 | env: |
| 286 | 329 | GH_TOKEN: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 287 | 330 | run: | |
| 288 | 331 | for ISSUE in $(echo $final_issues | jq -r '.[]'); do |
| 289 | 332 | gh issue edit $ISSUE -R ${{ github.repository }} --add-label "β Done (staging)" --remove-label "π§βπ» In Progress" |
| @@ -15,14 +15,25 @@ jobs: | ||
| 15 | 15 | check-merge-conflicts: |
| 16 | 16 | name: βοΈ Check Merge Conflicts |
| 17 | 17 | runs-on: ubuntu-latest |
| 18 | + if: always() | |
| 18 | 19 | |
| 19 | 20 | steps: |
| 21 | + - name: Mint App Token | |
| 22 | + id: app | |
| 23 | + # Create a GitHub App token | |
| 24 | + # https://github.com/marketplace/actions/create-github-app-token | |
| 25 | + uses: actions/create-github-app-token@v2 | |
| 26 | + with: | |
| 27 | + app-id: ${{ vars.ST_BOT_APP_ID }} | |
| 28 | + private-key: ${{ secrets.ST_BOT_PRIVATE_KEY }} | |
| 29 | + owner: ${{ github.repository_owner }} | |
| 30 | + | |
| 20 | 31 | - name: Check Merge Conflicts |
| 21 | 32 | # Label Conflicting Pull Requests |
| 22 | 33 | # https://github.com/marketplace/actions/label-conflicting-pull-requests |
| 23 | 34 | uses: eps1lon/actions-label-merge-conflict@v3.0.3 |
| 24 | 35 | with: |
| 25 | 36 | dirtyLabel: 'π« Merge Conflicts' |
| 26 | 37 | repoToken: ${{ secretssteps.ISSUES_BOT_TOKENapp.outputs.token }} |
| 27 | 38 | commentOnDirty: > |
| 28 | 39 | β οΈ This PR has conflicts that need to be resolved before it can be merged. |