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>pull/12725/head
parent
9ae0253f4e
commit
b8fa24b022
|
@ -34,32 +34,24 @@ jobs:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
# TODO: consider using https://github.com/docker/metadata-action instead of this
|
|
||||||
# custom magic
|
|
||||||
- name: Calculate docker image tag
|
- name: Calculate docker image tag
|
||||||
id: set-tag
|
id: set-tag
|
||||||
run: |
|
uses: docker/metadata-action@master
|
||||||
case "${GITHUB_REF}" in
|
with:
|
||||||
refs/heads/develop)
|
images: matrixdotorg/synapse
|
||||||
tag=develop
|
flavor: |
|
||||||
;;
|
latest=false
|
||||||
refs/heads/master|refs/heads/main)
|
tags: |
|
||||||
tag=latest
|
type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }}
|
||||||
;;
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
|
||||||
refs/tags/*)
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
||||||
tag=${GITHUB_REF#refs/tags/}
|
type=pep440,pattern={{raw}}
|
||||||
;;
|
|
||||||
*)
|
|
||||||
tag=${GITHUB_SHA}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo "::set-output name=tag::$tag"
|
|
||||||
|
|
||||||
- name: Build and push all platforms
|
- name: Build and push all platforms
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
labels: "gitsha1=${{ github.sha }}"
|
labels: "gitsha1=${{ github.sha }}"
|
||||||
tags: "matrixdotorg/synapse:${{ steps.set-tag.outputs.tag }}"
|
tags: "${{ steps.set-tag.outputs.tags }}"
|
||||||
file: "docker/Dockerfile"
|
file: "docker/Dockerfile"
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Update the "Build docker images" GitHub Actions workflow to use `docker/metadata-action` to generate docker image tags, instead of a custom shell script. Contributed by henryclw.
|
Loading…
Reference in New Issue