|
| 1 | +# Builds the secure-enclave EIF and pushes the carrier image to GHCR. |
| 2 | +# Pull requests build without publishing. |
| 3 | +name: Build Enclave EIF Image |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + paths: |
| 8 | + - "secure-enclave/**" |
| 9 | + - "shared/**" |
| 10 | + - "Cargo.toml" |
| 11 | + - "Cargo.lock" |
| 12 | + - "rust-toolchain.toml" |
| 13 | + - "scripts/build-eif.sh" |
| 14 | + - ".github/workflows/build-enclave-eif.yml" |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - main |
| 18 | + tags: |
| 19 | + - "v*" |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + version: |
| 23 | + description: "Version tag to publish (including v prefix, e.g. v0.1.0)" |
| 24 | + required: false |
| 25 | + type: string |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + |
| 30 | +env: |
| 31 | + NITRO_CLI_VERSION: v1.4.2 |
| 32 | + |
| 33 | +jobs: |
| 34 | + build-enclave-eif: |
| 35 | + name: Build enclave EIF + carrier image |
| 36 | + runs-on: ubuntu-latest |
| 37 | + permissions: |
| 38 | + contents: read |
| 39 | + id-token: write |
| 40 | + packages: write |
| 41 | + attestations: write |
| 42 | + steps: |
| 43 | + - name: Checkout code |
| 44 | + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 45 | + |
| 46 | + - name: Install Rust toolchain |
| 47 | + uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable |
| 48 | + |
| 49 | + - name: Cache nitro-cli build |
| 50 | + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 |
| 51 | + with: |
| 52 | + path: target/eif/aws-nitro-enclaves-cli-${{ env.NITRO_CLI_VERSION }} |
| 53 | + key: nitro-cli-${{ runner.os }}-${{ env.NITRO_CLI_VERSION }} |
| 54 | + |
| 55 | + - name: Resolve version |
| 56 | + id: version |
| 57 | + if: github.ref_type == 'tag' || inputs.version != '' |
| 58 | + env: |
| 59 | + INPUT_VERSION: ${{ inputs.version }} |
| 60 | + run: | |
| 61 | + if [[ -n "$INPUT_VERSION" ]]; then |
| 62 | + VERSION="$INPUT_VERSION" |
| 63 | + else |
| 64 | + VERSION="$GITHUB_REF_NAME" |
| 65 | + fi |
| 66 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 67 | + if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 68 | + echo "is_stable=true" >> "$GITHUB_OUTPUT" |
| 69 | + else |
| 70 | + echo "is_stable=false" >> "$GITHUB_OUTPUT" |
| 71 | + fi |
| 72 | +
|
| 73 | + - name: Prepare nitro-cli log directory |
| 74 | + run: sudo install -d -m 1777 /var/log/nitro_enclaves |
| 75 | + |
| 76 | + - name: Build EIF and PCRs |
| 77 | + run: scripts/build-eif.sh target/eif |
| 78 | + |
| 79 | + - name: Publish PCR measurements |
| 80 | + run: | |
| 81 | + { |
| 82 | + echo '### Enclave PCR measurements' |
| 83 | + echo '```json' |
| 84 | + cat target/eif/pcrs.json |
| 85 | + echo '```' |
| 86 | + } >> "$GITHUB_STEP_SUMMARY" |
| 87 | +
|
| 88 | + - name: Upload PCR measurements |
| 89 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 90 | + with: |
| 91 | + name: enclave-pcrs |
| 92 | + path: target/eif/pcrs.json |
| 93 | + if-no-files-found: error |
| 94 | + |
| 95 | + - name: Docker meta |
| 96 | + id: meta |
| 97 | + uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5 |
| 98 | + with: |
| 99 | + images: ghcr.io/${{ github.repository }}-enclave-eif |
| 100 | + tags: | |
| 101 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || steps.version.outputs.is_stable == 'true' }} |
| 102 | + type=sha |
| 103 | + type=raw,value=${{ steps.version.outputs.version }},enable=${{ steps.version.outputs.version != '' }} |
| 104 | +
|
| 105 | + - name: Set up Docker Buildx |
| 106 | + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 |
| 107 | + |
| 108 | + - name: Login to GitHub Container Registry |
| 109 | + if: github.event_name != 'pull_request' |
| 110 | + uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 |
| 111 | + with: |
| 112 | + registry: ghcr.io |
| 113 | + username: ${{ github.actor }} |
| 114 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + |
| 116 | + - name: Build and push carrier image |
| 117 | + id: build |
| 118 | + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 |
| 119 | + with: |
| 120 | + # Context is the EIF output dir so the .eif is always included. |
| 121 | + context: target/eif |
| 122 | + file: secure-enclave/Dockerfile.eif |
| 123 | + push: ${{ github.event_name != 'pull_request' }} |
| 124 | + tags: ${{ steps.meta.outputs.tags }} |
| 125 | + labels: ${{ steps.meta.outputs.labels }} |
| 126 | + platforms: linux/amd64 |
| 127 | + |
| 128 | + - name: Attest build provenance |
| 129 | + if: github.event_name != 'pull_request' |
| 130 | + uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1 |
| 131 | + with: |
| 132 | + push-to-registry: true |
| 133 | + subject-name: ghcr.io/${{ github.repository }}-enclave-eif |
| 134 | + subject-digest: ${{ steps.build.outputs.digest }} |
0 commit comments