|
| 1 | +name: Build and publish signed Docker image |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + multiarch-build: |
| 11 | + name: Build and publish signed image |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Load DCT delegation key |
| 21 | + env: |
| 22 | + DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ secrets.DCT_KEY_PASSPHRASE }} |
| 23 | + DCT_KEY_BASE64: ${{ secrets.DCT_KEY_BASE64 }} |
| 24 | + run: | |
| 25 | + echo "$DCT_KEY_BASE64" | base64 -d > delegation.key |
| 26 | + docker trust key load delegation.key --name gha |
| 27 | + rm delegation.key |
| 28 | +
|
| 29 | + - name: Get Docker tags |
| 30 | + id: docker_meta |
| 31 | + uses: docker/metadata-action@v5 |
| 32 | + with: |
| 33 | + images: | |
| 34 | + nginxproxy/${{ github.event.repository.name }} |
| 35 | + tags: | |
| 36 | + type=raw,value=signed |
| 37 | + labels: | |
| 38 | + org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag) |
| 39 | + flavor: | |
| 40 | + latest=false |
| 41 | +
|
| 42 | + - name: Set up QEMU |
| 43 | + uses: docker/setup-qemu-action@v3 |
| 44 | + |
| 45 | + - name: Set up Docker Buildx |
| 46 | + uses: docker/setup-buildx-action@v3 |
| 47 | + |
| 48 | + - name: Login to DockerHub |
| 49 | + uses: docker/login-action@v3 |
| 50 | + with: |
| 51 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 52 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Build and load the image |
| 55 | + id: docker_build |
| 56 | + uses: docker/build-push-action@v5 |
| 57 | + with: |
| 58 | + context: . |
| 59 | + platforms: linux/amd64 |
| 60 | + load: true |
| 61 | + sbom: true |
| 62 | + provenance: mode=max |
| 63 | + tags: ${{ steps.docker_meta.outputs.tags }} |
| 64 | + labels: ${{ steps.docker_meta.outputs.labels }} |
| 65 | + cache-from: type=gha |
| 66 | + cache-to: type=gha,mode=max |
| 67 | + |
| 68 | + - name: Sign the image |
| 69 | + env: |
| 70 | + DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ secrets.DCT_KEY_PASSPHRASE }} |
| 71 | + run: | |
| 72 | + docker trust sign nginxproxy/${{ github.event.repository.name }}:signed |
| 73 | +
|
| 74 | + - name: Verify the image signature |
| 75 | + run: | |
| 76 | + docker trust inspect --pretty nginxproxy/${{ github.event.repository.name }}:signed |
| 77 | +
|
| 78 | + - name: Images digests |
| 79 | + run: echo ${{ steps.docker_build.outputs.digest }} |
0 commit comments