Debian Codegraph @

crt/s2n/.github/workflows/codebuild.yml

raw symbols SCIP
1 ---
2 name: Codebuild
3
4 on:
5 push:
6 branches: [main]
7 # This event can use aws credentials, but runs against upstream code instead of PR code.
8 # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
9 # https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
10 pull_request_target:
11 branches: [main]
12 merge_group:
13 types: [checks_requested]
14 branches: [main]
15
16 jobs:
17 start:
18 runs-on: ubuntu-latest
19 permissions:
20 id-token: write
21 contents: read
22 env:
23 source_pr: pr/${{ github.event.pull_request.number }}
24 source_sha: ${{ github.sha }}
25 pr_author: ${{ github.event.pull_request.user.login }}
26 steps:
27 - uses: actions/checkout@v7
28
29 - name: Get permissions
30 id: get_permission
31 if: github.event_name == 'pull_request_target'
32 uses: octokit/[email protected]
33 with:
34 route: GET /repos/{repo}/collaborators/{author}/permission
35 repo: ${{ github.repository }}
36 author: ${{ github.event.pull_request.user.login }}
37 env:
38 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39
40 - name: Get credentials
41 uses: aws-actions/[email protected]
42 with:
43 role-to-assume: arn:aws:iam::024603541914:role/GitHubOIDCRole
44 role-session-name: ${{ github.run_id }}
45 aws-region: us-west-2
46
47 - name: Start Codebuild for SHA
48 # This version runs when PRs are added to the merge queue or merged to main
49 if: github.event_name != 'pull_request_target'
50 run: ./codebuild/bin/start_codebuild.sh $source_sha
51
52 - name: Start Codebuild for PR
53 # This version runs when PRs are created or updated
54 if: github.event_name == 'pull_request_target'
55 run: |
56 permission=$(jq -r '.permission' <<< '${{ steps.get_permission.outputs.data }}')
57 echo "$pr_author has permission '$permission'".
58 if [[ "$permission" == "admin" || "$permission" == "write" ]]; then
59 ./codebuild/bin/start_codebuild.sh $source_pr
60 else
61 echo "$pr_author does not have write permissions."
62 echo "A maintainer will need to manually run the Codebuild jobs."
63 echo ""
64 echo "Review the latest version of the PR to ensure that the code is safe to execute."
65 echo "Note the full SHA of the commit that you are reviewing."
66 echo "Run: ./codebuild/bin/start_codebuild.sh <full sha>"
67 echo "Warning: use the full SHA, NOT the PR number. The PR could be updated after your review."
68 fi