File: codebuild.yml

package info (click to toggle)
aws-crt-python 0.28.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,428 kB
  • sloc: ansic: 437,955; python: 27,657; makefile: 5,855; sh: 4,289; ruby: 208; java: 82; perl: 73; cpp: 25; xml: 11
file content (68 lines) | stat: -rw-r--r-- 2,649 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
name: Codebuild

on:
  push:
    branches: [main]
  # This event can use aws credentials, but runs against upstream code instead of PR code.
  # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
  # https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
  pull_request_target:
    branches: [main]
  merge_group:
    types: [checks_requested]
    branches: [main]

jobs:
  start:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    env:
      source_pr: pr/${{ github.event.pull_request.number }}
      source_sha: ${{ github.sha }}
      pr_author: ${{ github.event.pull_request.user.login }}
    steps:
      - uses: actions/checkout@v5

      - name: Get permissions
        id: get_permission
        if: github.event_name == 'pull_request_target'
        uses: octokit/request-action@v2.x
        with:
          route: GET /repos/{repo}/collaborators/{author}/permission
          repo: ${{ github.repository }}
          author: ${{ github.event.pull_request.user.login }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Get credentials
        uses: aws-actions/configure-aws-credentials@v5.0.0
        with:
          role-to-assume: arn:aws:iam::024603541914:role/GitHubOIDCRole
          role-session-name: ${{ github.run_id }}
          aws-region: us-west-2

      - name: Start Codebuild for SHA
        # This version runs when PRs are added to the merge queue or merged to main
        if: github.event_name != 'pull_request_target'
        run: ./codebuild/bin/start_codebuild.sh $source_sha

      - name: Start Codebuild for PR
        # This version runs when PRs are created or updated
        if: github.event_name == 'pull_request_target'
        run: |
          permission=$(jq -r '.permission' <<< '${{ steps.get_permission.outputs.data }}')
          echo "$pr_author has permission '$permission'".
          if [[ "$permission" == "admin" || "$permission" == "write" ]]; then
            ./codebuild/bin/start_codebuild.sh $source_pr
          else
            echo "$pr_author does not have write permissions."
            echo "A maintainer will need to manually run the Codebuild jobs."
            echo ""
            echo "Review the latest version of the PR to ensure that the code is safe to execute."
            echo "Note the full SHA of the commit that you are reviewing."
            echo "Run: ./codebuild/bin/start_codebuild.sh <full sha>"
            echo "Warning: use the full SHA, NOT the PR number. The PR could be updated after your review."
          fi