浏览代码

Publish tag to Docker Hub

This tags the versions released on Docker Hub so we
can rely on those versions rather than the sha.
James DiGioia 5 年之前
父节点
当前提交
beb0502fb4
共有 1 个文件被更改,包括 16 次插入3 次删除
  1. 16 3
      .github/workflows/docker.yml

+ 16 - 3
.github/workflows/docker.yml

@@ -52,6 +52,19 @@ jobs:
           restore-keys: |
           restore-keys: |
             ${{ runner.os }}-buildx-
             ${{ 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
       - name: Build and push
         id: docker_build
         id: docker_build
         uses: docker/build-push-action@v2
         uses: docker/build-push-action@v2
@@ -62,12 +75,12 @@ jobs:
           push: true
           push: true
           tags: |
           tags: |
             ${{ secrets.DOCKER_USERNAME }}/archivebox:latest
             ${{ secrets.DOCKER_USERNAME }}/archivebox:latest
-            ${{ secrets.DOCKER_USERNAME }}/archivebox:${{ github.sha }}
+            ${{ secrets.DOCKER_USERNAME }}/archivebox:${{ steps.publish.outputs.tag }}
             archivebox/archivebox:latest
             archivebox/archivebox:latest
-            archivebox/archivebox:${{ github.sha }}
+            archivebox/archivebox:${{ steps.publish.outputs.tag }}
           cache-from: type=local,src=/tmp/.buildx-cache
           cache-from: type=local,src=/tmp/.buildx-cache
           cache-to: type=local,dest=/tmp/.buildx-cache
           cache-to: type=local,dest=/tmp/.buildx-cache
           platforms: linux/amd64,linux/arm64,linux/arm/v7
           platforms: linux/amd64,linux/arm64,linux/arm/v7
-      
+
       - name: Image digest
       - name: Image digest
         run: echo ${{ steps.docker_build.outputs.digest }}
         run: echo ${{ steps.docker_build.outputs.digest }}