Improved docker push github action

This commit is contained in:
Esteban Sánchez 2023-11-21 09:24:33 +01:00
parent cb78dd1fb7
commit 723872bc15
No known key found for this signature in database
GPG Key ID: 9342C91BA286AB16

View File

@ -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 }}