|
| 1 | +name: Run Extras |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_review: |
| 5 | + types: [submitted] |
| 6 | + |
| 7 | +permissions: |
| 8 | + id-token: write # This is required for requesting the JWT |
| 9 | + |
| 10 | +jobs: |
| 11 | + check-comment: |
| 12 | + if: github.event.review.body == '/run slow' || github.event.review.body == '/run localmode' || github.event.review.body == '/run extras' |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Configure AWS Credentials |
| 16 | + uses: aws-actions/configure-aws-credentials@v4 |
| 17 | + with: |
| 18 | + role-to-assume: ${{ secrets.MONITORING_AWS_ROLE_ARN }} |
| 19 | + aws-region: us-west-2 |
| 20 | + - name: Collaborator Check |
| 21 | + uses: actions/github-script@v7 |
| 22 | + id: collab-check |
| 23 | + env: |
| 24 | + GH_USER_LOGIN: ${{ github.event.review.user.login }} |
| 25 | + with: |
| 26 | + github-token: ${{ secrets.COLLAB_CHECK_TOKEN }} |
| 27 | + result-encoding: string |
| 28 | + script: | |
| 29 | + try { |
| 30 | + const res = await github.rest.repos.checkCollaborator({ |
| 31 | + owner: context.repo.owner, |
| 32 | + repo: context.repo.repo, |
| 33 | + username: "${{ env.GH_USER_LOGIN }}", |
| 34 | + }); |
| 35 | + console.log("Verifed user is a repo collaborator.") |
| 36 | + return |
| 37 | + } catch (error) { |
| 38 | + if (error.message == "Bad credentials") { |
| 39 | + console.log("Token Expired. Please update the COLLAB_CHECK_TOKEN secret.") |
| 40 | + const { execSync } = require('child_process') |
| 41 | + execSync('aws cloudwatch put-metric-data --namespace "GitHubActions" --metric-name "BadCredentials" --value 1') |
| 42 | + } |
| 43 | + throw new Error("Collaborator status could not be verified.") |
| 44 | + } |
| 45 | + run-slow-tests: |
| 46 | + needs: [check-comment] |
| 47 | + if: needs.check-comment.result == 'success' && github.event.review.body == '/run slow' || github.event.review.body == '/run extras' |
| 48 | + uses: ./.github/workflows/trigger-codebuild.yml |
| 49 | + secrets: |
| 50 | + CI_AWS_ROLE_ARN: ${{ secrets.CI_AWS_ROLE_ARN }} |
| 51 | + with: |
| 52 | + codeBuildProjectName: "${{ github.event.repository.name }}-ci-slow-tests" |
| 53 | + prNumber: ${{ github.event.pull_request.number }} |
| 54 | + commitSha: ${{ github.event.pull_request.head.sha }} |
| 55 | + run-localmode-tests: |
| 56 | + needs: [check-comment] |
| 57 | + if: needs.check-comment.result == 'success' && github.event.review.body == '/run localmode' || github.event.review.body == '/run extras' |
| 58 | + uses: ./.github/workflows/trigger-codebuild.yml |
| 59 | + secrets: |
| 60 | + CI_AWS_ROLE_ARN: ${{ secrets.CI_AWS_ROLE_ARN }} |
| 61 | + with: |
| 62 | + codeBuildProjectName: "${{ github.event.repository.name }}-ci-localmode-tests" |
| 63 | + prNumber: ${{ github.event.pull_request.number }} |
| 64 | + commitSha: ${{ github.event.pull_request.head.sha }} |
0 commit comments