|
| 1 | +--- |
| 2 | +"name": "Build Notebooks (pr, RHEL images)" |
| 3 | +"on": |
| 4 | + "pull_request_target": |
| 5 | + |
| 6 | +# BEWARE: This GitHub Actions workflow runs on pull_request_target, meaning it has access to our secrets |
| 7 | +# see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-secrets |
| 8 | +# and https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + packages: read |
| 13 | + |
| 14 | +env: |
| 15 | + # language=json |
| 16 | + contributors: | |
| 17 | + ["atheo89", "andyatmiami", "caponetto", "daniellutz", "dibryant", "harshad16", "jesuino", "jiridanek", "jstourac", "paulovmr"] |
| 18 | +
|
| 19 | +jobs: |
| 20 | + gen: |
| 21 | + name: Generate job matrix |
| 22 | + runs-on: ubuntu-latest |
| 23 | + outputs: |
| 24 | + matrix: ${{ steps.gen.outputs.matrix }} |
| 25 | + has_jobs: ${{ steps.gen.outputs.has_jobs }} |
| 26 | + steps: |
| 27 | + |
| 28 | + - name: Check permissions and deny untrusted users (this must be done FIRST, for security, before we checkout) |
| 29 | + if: ${{ !contains(fromJSON(env.contributors), github.actor) }} |
| 30 | + run: | |
| 31 | + echo "GitHub user ${{ github.actor }} is not a registered project contributor, not allowed to run actions on RHEL!" |
| 32 | + exit 1 |
| 33 | +
|
| 34 | + # Here we are checking out the pull request, so that we can build from the new code |
| 35 | + # We can do this because we already checked that the submitting user is a contributor |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + if: ${{ github.event_name == 'pull_request_target' }} |
| 38 | + with: |
| 39 | + ref: "refs/pull/${{ github.event.number }}/merge" |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + if: ${{ github.event_name != 'pull_request_target' }} |
| 42 | + |
| 43 | + - name: Determine targets to build based on changed files |
| 44 | + if: ${{ github.event_name == 'pull_request_target' }} |
| 45 | + run: | |
| 46 | + set -x |
| 47 | + git fetch --no-tags origin 'pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}' |
| 48 | + git fetch --no-tags origin '+refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}' |
| 49 | + python3 ci/cached-builds/gen_gha_matrix_jobs.py \ |
| 50 | + --from-ref 'origin/${{ github.event.pull_request.base.ref }}' \ |
| 51 | + --to-ref '${{ github.event.pull_request.head.ref }}' \ |
| 52 | + --rhel-images include-only |
| 53 | + id: gen |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + shell: bash |
| 57 | + |
| 58 | + build: |
| 59 | + needs: ["gen"] |
| 60 | + strategy: |
| 61 | + fail-fast: false |
| 62 | + matrix: "${{ fromJson(needs.gen.outputs.matrix) }}" |
| 63 | + uses: ./.github/workflows/build-notebooks-TEMPLATE.yaml |
| 64 | + if: ${{ fromJson(needs.gen.outputs.has_jobs) }} |
| 65 | + with: |
| 66 | + target: "${{ matrix.target }}" |
| 67 | + github: "${{ toJSON(github) }}" |
| 68 | + subscription: "${{ matrix.subscription }}" |
| 69 | + secrets: inherit |
0 commit comments