From 39b8ea5d24fda6a8463cd7b53df1c667e99c9d77 Mon Sep 17 00:00:00 2001 From: Trong Huu Nguyen Date: Wed, 5 Jul 2023 09:57:31 +0200 Subject: [PATCH] ci: use platform-build-push-sign --- .github/workflows/deploy.yml | 77 +++++------------------------------- 1 file changed, 10 insertions(+), 67 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index af4c080..7bc8fa6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,9 +8,9 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout latest code - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # ratchet:actions/checkout@v3 + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # ratchet:actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # ratchet:actions/setup-go@v3 + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # ratchet:actions/setup-go@v3 with: go-version: ">=1.20.5" - name: Test Go @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # ratchet:actions/checkout@v3 + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # ratchet:actions/checkout@v3 - name: Install cosign uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 # ratchet:sigstore/cosign-installer@main with: @@ -37,69 +37,12 @@ jobs: run: cosign verify --certificate-identity "https://github.com/chainguard-images/images/.github/workflows/release.yaml@refs/heads/main" --certificate-oidc-issuer "https://token.actions.githubusercontent.com" cgr.dev/chainguard/go:1.20 - name: Verify runner image run: cosign verify --certificate-oidc-issuer https://accounts.google.com --certificate-identity keyless@distroless.iam.gserviceaccount.com gcr.io/distroless/static-debian11:nonroot - - id: "auth" - name: "Authenticate to Google Cloud" - uses: "google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033" # ratchet:google-github-actions/auth@v1 + - uses: nais/platform-build-push-sign@8a57d4c61477b4d586b863e79299a6c596901057 # ratchet:nais/platform-build-push-sign@main + id: build_push_sign with: - workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }} - service_account: "gh-wonderwall@nais-io.iam.gserviceaccount.com" - token_format: "access_token" - - name: Set up QEMU - uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # ratchet:docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@16c0bc4a6e6ada2cfd8afd41d22d95379cf7c32a # ratchet:docker/setup-buildx-action@v2 - - name: Login to Google Artifact Registry - uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # ratchet:docker/login-action@v2 - with: - registry: ${{ env.GOOGLE_REGISTRY }} - username: "oauth2accesstoken" - password: "${{ steps.auth.outputs.access_token }}" - - name: Login to GitHub Container Registry - uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # ratchet:docker/login-action@v2 - with: - registry: ${{ env.GITHUB_REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker meta - id: metadata - uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # ratchet:docker/metadata-action@v4 - with: - images: | - ${{ env.GOOGLE_REGISTRY }}/wonderwall - ${{ env.GITHUB_REGISTRY }}/${{ github.repository }} - flavor: | - latest=true - # Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern=v{{version}} - type=semver,pattern=v{{major}}.{{minor}} - type=semver,pattern=v{{major}} - type=sha,prefix={{date 'YYYY-MM-DD'}}- - - name: Build and push - id: build-push - uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # ratchet:docker/build-push-action@v4 - with: - context: . - file: Dockerfile - platforms: linux/amd64,linux/arm64 - pull: true + name: wonderwall + dockerfile: Dockerfile + google_service_account: gh-wonderwall push: true - tags: ${{ steps.metadata.outputs.tags }} - labels: ${{ steps.metadata.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Sign the container image for GAR - run: cosign sign --yes ${{ env.GOOGLE_REGISTRY }}/wonderwall@${{ steps.build-push.outputs.digest }} - - name: Create SBOM - uses: aquasecurity/trivy-action@41f05d9ecffa2ed3f1580af306000f734b733e54 # ratchet:aquasecurity/trivy-action@master - with: - scan-type: 'image' - format: 'cyclonedx' - output: 'cyclone.sbom.json' - image-ref: ${{ env.GOOGLE_REGISTRY }}/wonderwall@${{ steps.build-push.outputs.digest }} - - name: Attest - run: cosign attest --yes --predicate cyclone.sbom.json --type cyclonedx ${{ env.GOOGLE_REGISTRY }}/wonderwall@${{ steps.build-push.outputs.digest }} + push_ghcr: true + workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}