feat: add POST /v1/enclave-assignment and an attestation-verifying client #47
Workflow file for this run
This file contains hidden or 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
| # Builds the host-side `api` image and pushes it to the GitHub Container | |
| # Registry (attested). | |
| name: Build and Push Docker Image | |
| on: | |
| pull_request: | |
| paths: | |
| - "api/**" | |
| - "shared/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - "rust-toolchain.toml" | |
| - "Dockerfile" | |
| - ".dockerignore" | |
| - ".github/workflows/build-docker.yml" | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version tag to publish (including v prefix, e.g. v0.1.0)" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: read | |
| jobs: | |
| docker-build: | |
| name: Docker build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| packages: write | |
| attestations: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 | |
| - name: Mint biometric-engines access token | |
| id: biometric-engines-token | |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 | |
| with: | |
| client-id: ${{ secrets.BIOMETRIC_ENGINES_APP_ID }} | |
| private-key: ${{ secrets.BIOMETRIC_ENGINES_APP_PRIVATE_KEY }} | |
| owner: worldcoin | |
| repositories: biometric-engines | |
| - name: Resolve version | |
| id: version | |
| if: github.ref_type == 'tag' || inputs.version != '' | |
| env: | |
| INPUT_VERSION: ${{ inputs.version }} | |
| run: | | |
| if [[ -n "$INPUT_VERSION" ]]; then | |
| VERSION="$INPUT_VERSION" | |
| else | |
| VERSION="$GITHUB_REF_NAME" | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| # `latest` only for stable semver (no -alpha / -rc suffix). | |
| if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "is_stable=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "is_stable=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || steps.version.outputs.is_stable == 'true' }} | |
| type=sha | |
| type=raw,value=${{ steps.version.outputs.version }},enable=${{ steps.version.outputs.version != '' }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 | |
| - name: Login to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| id: build | |
| uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 | |
| with: | |
| context: . | |
| # Publish on push/tag/dispatch; PRs build only (validation). | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: linux/amd64 | |
| secrets: | | |
| GITHUB_TOKEN=${{ steps.biometric-engines-token.outputs.token }} | |
| - name: Attest build provenance | |
| if: github.event_name != 'pull_request' | |
| uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1 | |
| with: | |
| push-to-registry: true | |
| subject-name: ghcr.io/${{ github.repository }} | |
| subject-digest: ${{ steps.build.outputs.digest }} |