Skip to content

Fix docker-publish.yml #106

Fix docker-publish.yml

Fix docker-publish.yml #106

name: ci
on:
push:
branches:
- 'main'
tags:
- '*'
jobs:
docker:
runs-on: self-hosted
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: amd64,arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract version from tag
if: startsWith(github.ref, 'refs/tags/')
shell: pwsh
run: |
$TAG_VERSION = $env:GITHUB_REF -replace '^refs/tags/', ''
Add-Content -Path $env:GITHUB_ENV -Value "TAG_VERSION=$TAG_VERSION"
Write-Output "Using TAG_VERSION=$TAG_VERSION"
- name: Fail if TAG_VERSION is empty
if: startsWith(github.ref, 'refs/tags/') && env.TAG_VERSION == ''
run: |
echo "Error: TAG_VERSION is empty!"
exit 1
- name: Build and push (main branch)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: jocxfin/pwgen:latest
- name: Build and push (tags)
if: startsWith(github.ref, 'refs/tags/') && env.TAG_VERSION != ''
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: |
jocxfin/pwgen:${{ env.TAG_VERSION }}
jocxfin/pwgen:latest