diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index ceb8d46..10ce18a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,8 +1,5 @@ name: Publish Docker image -env: - DOCKERHUB_IMAGE: matrix-commander - # on: push # on: pull_request # on: @@ -24,10 +21,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Read VERSION file - id: getversion - run: echo "::set-output name=version::$(cat VERSION)" - # Required if building multi-arch images - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -45,10 +38,23 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} + # generate Docker tags based on the following events/attributes + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - name: Build and push uses: docker/build-push-action@v3 with: file: docker/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE }}:latest, ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE }}:${{ steps.getversion.outputs.version }} + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }}