name: Build Branch Image on: push: branches: - dev - staging - unstable # Cancel an in-flight build for a branch if a new push arrives before it finishes — avoids wasting runner minutes racing two builds of the same branch. concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read packages: write env: IMAGE_NAME: ghcr.io/${{ github.repository }} jobs: build-and-push: runs-on: ubuntu-latest timeout-minutes: 60 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: Log in to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE_NAME }} tags: | type=raw,value=${{ github.ref_name == 'dev' && 'latest' || github.ref_name }} type=sha,format=short,prefix=${{ github.ref_name == 'dev' && 'latest' || github.ref_name }}- - name: Build and push uses: docker/build-push-action@v6 with: context: . push: true platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha,scope=${{ github.ref_name }} cache-to: type=gha,mode=max,scope=${{ github.ref_name }} sbom: true provenance: true