summary refs log tree commit diff
path: root/.github
diff options
context:
space:
mode:
authorHenry <97804910+henryclw@users.noreply.github.com>2022-05-05 05:36:42 -0700
committerGitHub <noreply@github.com>2022-05-05 12:36:42 +0000
commitb8fa24b022df366495147b5ddce73c06ec9cbc3a (patch)
tree646a5a02285144e353615616f97ed0f07102cfca /.github
parentUse `private` instead of `hidden` in MSC2285 related code. (#12635) (diff)
downloadsynapse-b8fa24b022df366495147b5ddce73c06ec9cbc3a.tar.xz
Use `docker/metadata-action` to generate docker image tags (#12573)
Update the "Build docker images" GitHub Actions workflow to use
`docker/metadata-action` to generate docker image tags, instead of a
custom shell script.

Signed-off-by: Henry <97804910+henryclw@users.noreply.github.com>
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/docker.yml30
1 files changed, 11 insertions, 19 deletions
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 124b17458f..d20d30c035 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -34,32 +34,24 @@ jobs:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
 
-      # TODO: consider using https://github.com/docker/metadata-action instead of this
-      # custom magic
       - name: Calculate docker image tag
         id: set-tag
-        run: |
-          case "${GITHUB_REF}" in
-              refs/heads/develop)
-                  tag=develop
-                  ;;
-              refs/heads/master|refs/heads/main)
-                  tag=latest
-                  ;;
-              refs/tags/*)
-                  tag=${GITHUB_REF#refs/tags/}
-                  ;;
-              *)
-                  tag=${GITHUB_SHA}
-                  ;;
-          esac
-          echo "::set-output name=tag::$tag"
+        uses: docker/metadata-action@master
+        with:
+          images: matrixdotorg/synapse
+          flavor: |
+            latest=false
+          tags: |
+            type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }}
+            type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
+            type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
+            type=pep440,pattern={{raw}}
 
       - name: Build and push all platforms
         uses: docker/build-push-action@v2
         with:
           push: true
           labels: "gitsha1=${{ github.sha }}"
-          tags: "matrixdotorg/synapse:${{ steps.set-tag.outputs.tag }}"
+          tags: "${{ steps.set-tag.outputs.tags }}"
           file: "docker/Dockerfile"
           platforms: linux/amd64,linux/arm64