name: Publish Docker Image on: push: branches: - main tags: - "v*.*.*" workflow_dispatch: permissions: contents: read packages: write jobs: publish: runs-on: ubuntu-latest env: HAS_DOCKERHUB: ${{ secrets.DOCKERHUB_USERNAME }} steps: - name: Checkout uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Login to Docker Hub if: ${{ env.HAS_DOCKERHUB != '' }} uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract image metadata id: meta uses: docker/metadata-action@v5 with: images: | ghcr.io/srbhr/resume-matcher ${{ env.HAS_DOCKERHUB != '' && 'srbhr/resume-matcher' || '' }} tags: | type=raw,value=latest,enable={{is_default_branch}} type=semver,pattern={{version}},value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/v') }} - name: Build and push uses: docker/build-push-action@v6 with: context: . file: Dockerfile push: true platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max