From beb0502fb47196e13910405e48da76d84cbcae48 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Sun, 10 Jan 2021 17:08:00 -0500 Subject: [PATCH 1/3] Publish tag to Docker Hub This tags the versions released on Docker Hub so we can rely on those versions rather than the sha. --- .github/workflows/docker.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1d8c14e7..c624cec3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -52,6 +52,19 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- + - name: Get publish tag + id: publish + run: | + if [[ $GITHUB_REF != refs/tags/* ]]; then + TAG="${GITHUB_REF##*/}" + else + TAG=$GITHUB_SHA + fi + echo ::set-output name=tag::${TAG} + env: + GITHUB_REF: ${{ github.ref }} + GITHUB_SHA: ${{ github.sha }} + - name: Build and push id: docker_build uses: docker/build-push-action@v2 @@ -62,12 +75,12 @@ jobs: push: true tags: | ${{ secrets.DOCKER_USERNAME }}/archivebox:latest - ${{ secrets.DOCKER_USERNAME }}/archivebox:${{ github.sha }} + ${{ secrets.DOCKER_USERNAME }}/archivebox:${{ steps.publish.outputs.tag }} archivebox/archivebox:latest - archivebox/archivebox:${{ github.sha }} + archivebox/archivebox:${{ steps.publish.outputs.tag }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache platforms: linux/amd64,linux/arm64,linux/arm/v7 - + - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} From 8cdf43ec378a0a7928c04b821c6180eccb59c6cd Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Sun, 10 Jan 2021 19:07:50 -0500 Subject: [PATCH 2/3] Fix tag logic --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c624cec3..8efe5c27 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -55,8 +55,8 @@ jobs: - name: Get publish tag id: publish run: | - if [[ $GITHUB_REF != refs/tags/* ]]; then - TAG="${GITHUB_REF##*/}" + if [[ $GITHUB_REF == refs/tags/* ]]; then + TAG="${GITHUB_REF#refs/tags/}" else TAG=$GITHUB_SHA fi From c5b7d9f2bf527c4ae42dc462c85f7974be868738 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Wed, 13 Jan 2021 09:07:12 -0500 Subject: [PATCH 3/3] Publish, minor, & major version to DockerHub --- .github/workflows/docker.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8efe5c27..2a85086a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -52,15 +52,24 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - - name: Get publish tag - id: publish + - name: Prepare tags to publish + id: prep run: | + # Always publish to latest. + TAGS="${{ secrets.DOCKER_USERNAME }}/archivebox:latest,archivebox/archivebox:latest" if [[ $GITHUB_REF == refs/tags/* ]]; then - TAG="${GITHUB_REF#refs/tags/}" + VERSION="${GITHUB_REF#refs/tags/}" + MINOR=${VERSION%.*} + MAJOR=${MINOR%.*} + TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/archivebox:$VERSION,archivebox/archivebox:$VERSION" + TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/archivebox:$MINOR,archivebox/archivebox:$MINOR" + TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/archivebox:$MAJOR,archivebox/archivebox:$MAJOR" else - TAG=$GITHUB_SHA + VERSION=$GITHUB_SHA + TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/archivebox:$VERSION,archivebox/archivebox:$VERSION" fi - echo ::set-output name=tag::${TAG} + + echo ::set-output name=tags::${TAGS} env: GITHUB_REF: ${{ github.ref }} GITHUB_SHA: ${{ github.sha }} @@ -73,11 +82,7 @@ jobs: file: ./Dockerfile builder: ${{ steps.buildx.outputs.name }} push: true - tags: | - ${{ secrets.DOCKER_USERNAME }}/archivebox:latest - ${{ secrets.DOCKER_USERNAME }}/archivebox:${{ steps.publish.outputs.tag }} - archivebox/archivebox:latest - archivebox/archivebox:${{ steps.publish.outputs.tag }} + tags: ${{ steps.prep.outputs.tags }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache platforms: linux/amd64,linux/arm64,linux/arm/v7