Update security-monitoring.yml for codeql #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Checks | |
on: | |
pull_request_target: | |
branches: | |
- "main*" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }} | |
cancel-in-progress: true | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
jobs: | |
collab-check: | |
runs-on: ubuntu-latest | |
outputs: | |
approval-env: ${{ steps.collab-check.outputs.result }} | |
steps: | |
- name: Collaborator Check | |
uses: actions/github-script@v7 | |
id: collab-check | |
with: | |
github-token: ${{ secrets.COLLAB_CHECK_TOKEN }} | |
result-encoding: string | |
script: | | |
try { | |
const res = await github.rest.repos.checkCollaborator({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
username: "${{ github.event.pull_request.user.login }}", | |
}); | |
console.log("Verifed ${{ github.event.pull_request.user.login }} is a repo collaborator. Auto Approving PR Checks.") | |
return res.status == "204" ? "auto-approve" : "manual-approval" | |
} catch (error) { | |
console.log("${{ github.event.pull_request.user.login }} is not a collaborator. Requiring Manual Approval to run PR Checks.") | |
return "manual-approval" | |
} | |
wait-for-approval: | |
runs-on: ubuntu-latest | |
needs: [collab-check] | |
environment: ${{ needs.collab-check.outputs.approval-env }} | |
steps: | |
- run: echo "Workflow Approved! Starting PR Checks." | |
unit-tests: | |
runs-on: ubuntu-latest | |
needs: [wait-for-approval] | |
strategy: | |
matrix: | |
python-version: ["38", "39", "310", "311"] | |
steps: | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} | |
aws-region: us-west-2 | |
role-duration-seconds: 3600 | |
- name: Run Unit Tests in Python ${{ matrix.python-version }} | |
uses: aws-actions/aws-codebuild-run-build@v1 | |
with: | |
project-name: ${{ secrets.UNIT_TEST_PROJECT_PREFIX }}${{ matrix.python-version }} | |
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}' | |
integration-tests: | |
runs-on: ubuntu-latest | |
needs: [wait-for-approval] | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["38", "39", "310", "311"] | |
steps: | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} | |
aws-region: us-west-2 | |
role-duration-seconds: 3600 | |
- name: Run Integration Tests in Python ${{ matrix.python-version }} | |
uses: aws-actions/aws-codebuild-run-build@v1 | |
with: | |
project-name: ${{ secrets.INTEGRATION_TEST_PROJECT_PREFIX }}${{ matrix.python-version }} | |
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}' |