name: Build & Push Multi-Arch Image on: push: branches: [main] tags: - "v*.*.*" # Triggers on version tags like v1.0.0 workflow_dispatch: # Allow manual trigger from GitHub UI env: IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/ost2pst jobs: build-and-push: runs-on: ubuntu-latest steps: # ── Checkout source ───────────────────────────────────────────────────── - name: Checkout uses: actions/checkout@v4 # ── Set up QEMU (required for ARM64 emulation on GitHub runners) ──────── - name: Set up QEMU uses: docker/setup-qemu-action@v3 # ── Set up Buildx (multi-arch builder) ────────────────────────────────── - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # ── Log in to Docker Hub ───────────────────────────────────────────────── - name: Log in to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} # ── Determine image tags ───────────────────────────────────────────────── - name: Extract metadata (tags, labels) id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE_NAME }} tags: | # Push :latest on every main branch commit type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} # Push semver tags: v1.2.3 → 1.2.3, 1.2, 1 type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} # Always tag with the short commit SHA type=sha,prefix=sha- # ── Build & push for linux/amd64 + linux/arm64 ────────────────────────── - name: Build and push uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} # Layer caching via GitHub Actions cache — speeds up subsequent builds cache-from: type=gha cache-to: type=gha,mode=max