From 9c02930a8b67b2d729ace1e0f60894060a2301a9 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Sat, 8 Jun 2024 00:02:04 +0100 Subject: [PATCH] tweak: Switch to the official Docker build script --- .github/workflows/release.yml | 66 ++++++++++++++++------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fb0028d..ecbf4b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,18 +30,12 @@ jobs: steps: - uses: actions/checkout@v4 - - - name: Build Dockerfile - run: docker build . --file Dockerfile --tag image --platform linux/amd64,linux/arm64 - - - run: | - docker run --rm -t -v $PWD:/volume image cp /app/$HANDLER_NAME /volume/handler - mv ./handler ./$HANDLER_NAME - - name: Save handler artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.HANDLER_NAME }} - path: ${{ env.HANDLER_NAME }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log into registries if: github.event_name == 'push' @@ -55,30 +49,30 @@ jobs: run: | VERSION=$(git describe --tags 2>/dev/null || git rev-parse --short HEAD) echo "::set-output name=version::$VERSION" - - - name: Push image to GitHub - if: github.event_name == 'push' - run: | - IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/${{ github.event.repository.name }} - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - docker tag image $IMAGE_ID:latest - docker push $IMAGE_ID:latest - docker tag image $IMAGE_ID:${{ steps.version.outputs.version }} - docker push $IMAGE_ID:${{ steps.version.outputs.version }} - - - name: Push image to Docker Hub - if: github.event_name == 'push' - run: | - IMAGE_ID=${{ env.IMAGE }} - echo IMAGE_ID=$IMAGE_ID - docker tag image $IMAGE_ID:latest - docker push $IMAGE_ID:latest - docker tag image $IMAGE_ID:${{ steps.version.outputs.version }} - docker push $IMAGE_ID:${{ steps.version.outputs.version }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + labels: org.opencontainers.image.authors=SierraSoftworks,org.opencontainers.image.version=${{ steps.version.outputs.version }},org.opencontainers.image.revision=${{ github.sha }} + tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ steps.version.outputs.version }},docker.pkg.github.com/${{ github.repository }}/${{ github.event.repository.name }}:latest,docker.pkg.github.com/${{ github.repository }}/${{ github.event.repository.name }}:${{ steps.version.outputs.version }} + + - run: | + docker run --rm -t -v $PWD:/volume ${{ env.IMAGE }}:${{ steps.version.outputs.version }} cp /app/$HANDLER_NAME /volume/handler + mv ./handler ./$HANDLER_NAME + + - name: Save handler artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.HANDLER_NAME }} + path: ${{ env.HANDLER_NAME }} + deploy-staging: needs: build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest if: github.actor != 'dependabot[bot]' environment: name: Staging @@ -107,7 +101,7 @@ jobs: healthcheck-staging: needs: deploy-staging - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Probe @@ -125,7 +119,7 @@ jobs: name: Production url: ${{ env.LIVE_HEALTHCHECK }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -150,7 +144,7 @@ jobs: healthcheck-live: needs: deploy-live - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Probe