From f377bde053a7822796981545447b10335b8d678f Mon Sep 17 00:00:00 2001 From: Trevor Sharp Date: Sun, 4 Aug 2024 15:02:37 +0000 Subject: [PATCH] Update github actions --- .github/workflows/docker-main.yml | 35 ++++++++++--------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/.github/workflows/docker-main.yml b/.github/workflows/docker-main.yml index f27ec8b..6d216a8 100644 --- a/.github/workflows/docker-main.yml +++ b/.github/workflows/docker-main.yml @@ -1,66 +1,53 @@ -name: Build Docker Image +name: Build and Push Docker Image on: workflow_dispatch: push: branches: [main] - tags: "v*.*.*" + tags: 'v*.*.*' jobs: build: - name: "Build and Push Docker Image" + name: 'Build and Push Docker Image' runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Prepare Tags - id: prep + id: tags run: | DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} - VERSION=${GITHUB_REF##*/} - # If this is the main branch, use 'latest' instead - if [[ $GITHUB_REF == refs/heads/main ]]; then + if [[ $VERSION == main ]]; then VERSION=latest fi - TAGS="${DOCKER_IMAGE}:${VERSION}" - - # If the version is a version number, also tag with 'latest' - if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - TAGS="$TAGS,${DOCKER_IMAGE}:latest" - fi - - # Tag with the GitHub run id to create a unique tag for this run - TAGS="$TAGS,${DOCKER_IMAGE}:${GITHUB_RUN_ID}" - + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${GITHUB_RUN_ID}" echo "tags=${TAGS}" >> $GITHUB_OUTPUT - echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 with: platforms: all - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to Docker - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and Push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: builder: ${{ steps.buildx.outputs.name }} context: . file: ./Dockerfile platforms: linux/amd64 push: true - tags: ${{ steps.prep.outputs.tags }} + tags: ${{ steps.tags.outputs.tags }}