diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b6b6e35c..857e611b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,6 +24,25 @@ jobs: id: buildx uses: docker/setup-buildx-action@v2 + - name: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: | + estrellaxd/auto_bangumi + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest + + - name: Login to DockerHub + if: ${{ github.event_name == 'push' }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Build and push uses: docker/build-push-action@v4 with: @@ -31,9 +50,7 @@ jobs: builder: ${{ steps.buildx.output.name }} platforms: linux/amd64,linux/arm64,linux/arm push: ${{ github.event_name == 'push' }} - tags: | - estrellaxd/auto_bangumi:latest - estrellaxd/auto_bangumi:${{ github.ref_name }} + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha, scope=${{ github.workflow }} cache-to: type=gha, scope=${{ github.workflow }}