|
| 1 | +name: Build and Publish image to Docker Hub |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - 'master' |
| 6 | + tags: |
| 7 | + - 'v*.*.*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_and_push: |
| 11 | + env: |
| 12 | + DOCKER_HUB: ${{ secrets.DOCKER_LOGIN }} |
| 13 | + DOCKER_TAGS: type=ref,event=branch,branch=master,latest=true |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + permissions: |
| 16 | + id-token: write |
| 17 | + attestations: write |
| 18 | + contents: read |
| 19 | + packages: write |
| 20 | + |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + target: |
| 24 | + - name: stone-prover |
| 25 | + dockerfile: Dockerfile |
| 26 | + - name: cpu_air_prover |
| 27 | + dockerfile: air_prover/Dockerfile |
| 28 | + - name: cpu_air_verifier |
| 29 | + dockerfile: air_verifier/Dockerfile |
| 30 | + continue-on-error: true |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v3 |
| 38 | + |
| 39 | + - name: Log in to Docker Hub |
| 40 | + uses: docker/login-action@v3 |
| 41 | + with: |
| 42 | + username: ${{ secrets.DOCKER_LOGIN }} |
| 43 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 44 | + |
| 45 | + - name: Determine Docker Tags |
| 46 | + id: set-tag |
| 47 | + run: | |
| 48 | + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then |
| 49 | + TAG_NAME=$(echo ${GITHUB_REF} | sed 's/refs\/tags\///') |
| 50 | + echo "DOCKER_TAGS=${TAG_NAME}" >> $GITHUB_ENV |
| 51 | + else |
| 52 | + echo "No valid ref for tagging. Exiting..." |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + shell: bash |
| 56 | + |
| 57 | + - name: Set image tags & labels |
| 58 | + id: meta |
| 59 | + uses: docker/metadata-action@v5 |
| 60 | + with: |
| 61 | + images: ${{ env.DOCKER_HUB }}/${{ matrix.target.name }} |
| 62 | + tags: ${{ env.DOCKER_TAGS }} |
| 63 | + |
| 64 | + - name: Build And Push Image |
| 65 | + id: push |
| 66 | + uses: docker/build-push-action@v6 |
| 67 | + with: |
| 68 | + context: . |
| 69 | + file: ${{ matrix.target.dockerfile }} |
| 70 | + push: true |
| 71 | + tags: ${{ steps.meta.outputs.tags }} |
| 72 | + labels: ${{ steps.meta.outputs.labels }} |
| 73 | + |
| 74 | + - name: Generate artifact attestation |
| 75 | + if: github.event.repository.fork == false |
| 76 | + uses: actions/attest-build-provenance@v1 |
| 77 | + with: |
| 78 | + subject-name: ${{ secrets.DOCKER_LOGIN }}/${{ matrix.target.name }} |
| 79 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 80 | + push-to-registry: true |
| 81 | + |
0 commit comments