diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 537c8db..45fcd60 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,16 +19,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Extract branch name - shell: bash - run: | - tag=${GITHUB_REF#refs/tags/} - tag=${tag#refs/heads/} - if echo $tag | grep -q -E "[0-9]+\.[0-9]+\.[0-9]+"; then - tag="v$tag" - fi - echo "##[set-output name=tag;]$tag" - id: extract_branch + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + flavor: | + latest=auto + images: ${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter - name: Login to DockerHub uses: docker/login-action@v3 @@ -41,22 +38,26 @@ jobs: with: push: true platforms: linux/amd64,linux/arm64,linux/386 - tags: | - ${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:latest - ${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:${{ steps.extract_branch.outputs.tag }} + tags: ${{ steps.meta.outputs.tags }} + + - name: Docker meta + id: metaghcr + uses: docker/metadata-action@v5 + with: + flavor: | + latest=auto + images: ${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter - name: Login to Github Container Registry uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.GHCR_PERSONAL_TOKEN }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push docker to Github Container Registry uses: docker/build-push-action@v5 with: push: true platforms: linux/amd64,linux/arm64,linux/386 - tags: | - ghcr.io/${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:latest - ghcr.io/${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:${{ steps.extract_branch.outputs.tag }} + tags: ${{ steps.metaghcr.outputs.tags }}