From 40998292331ad9e0b4657f5b4a752ac1112392be Mon Sep 17 00:00:00 2001 From: yojoshb <68751897+yojoshb@users.noreply.github.com> Date: Thu, 11 Apr 2024 02:13:39 -0500 Subject: [PATCH] simplify build --- .github/workflows/docker-publish.yml | 41 +++++----------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b6953e0..772e1d5 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -6,8 +6,6 @@ on: workflow_dispatch: push: branches: [ "main" ] - # Publish semver tags as releases. - tags: [ 'v*.*.*' ] paths-ignore: - ".github/**" - "README.md" @@ -15,7 +13,6 @@ on: branches: [ "main" ] env: - # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }} @@ -26,19 +23,16 @@ jobs: permissions: contents: read packages: write - # This is used to complete the identity challenge with sigstore/fulcio when running outside of PRs. - id-token: write steps: - name: Checkout repository uses: actions/checkout@v4 - # Install the cosign tool except on PR https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@v3.5.0 + - name: Set up QEMU uses: docker/setup-qemu-action@v3 + - name: Setup Docker buildx uses: docker/setup-buildx-action@v3 + - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' uses: docker/login-action@v3 @@ -46,13 +40,14 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata id: meta uses: docker/metadata-action@v4 with: flavor: latest=true images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: type=sha,format=long + - name: Build and push Docker image id: build-and-push uses: docker/build-push-action@v5 @@ -62,27 +57,5 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # Sign the resulting Docker image digest except on PRs. https://github.com/sigstore/cosign - - name: Sign image with a key - if: ${{ github.event_name != 'pull_request' }} - run: | - images="" - for tag in ${TAGS}; do - images+="${tag}@${DIGEST} " - done - cosign sign --yes --key env://COSIGN_PRIVATE_KEY ${images} - env: - TAGS: ${{ steps.meta.outputs.tags }} - COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} - COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} - DIGEST: ${{ steps.build-and-push.outputs.digest }} - - name: Sign the images with GitHub OIDC Token - env: - DIGEST: ${{ steps.build-and-push.outputs.digest }} - TAGS: ${{ steps.meta.outputs.tags }} - run: | - images="" - for tag in ${TAGS}; do - images+="${tag}@${DIGEST} " - done - cosign sign --yes ${images} + cache-from: type=gha + cache-to: type=gha,mode=max