name: Build the Postgres image on: workflow_dispatch concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }}/pg jobs: build: runs-on: ${{ matrix.runner }} permissions: packages: write strategy: fail-fast: false matrix: include: - arch: amd64 platform: linux/amd64 runner: ubuntu-latest - arch: arm64 platform: linux/arm64 runner: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} flavor: | suffix=-${{ matrix.arch }},onlatest=true tags: | type=raw,value=latest,enable={{is_default_branch}} - name: Login GHCR uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: | image=moby/buildkit:latest network=host - name: Build & Push single platform id: build uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile.pg platforms: ${{ matrix.platform }} push: true labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true cache-from: type=gha cache-to: type=gha,mode=max - name: Export digest run: echo "${{ steps.build.outputs.digest }}" > /tmp/digest-${{ matrix.arch }} - name: Upload digest artifact uses: actions/upload-artifact@v4 with: name: digest-${{ matrix.arch }} path: /tmp/digest-${{ matrix.arch }} if-no-files-found: error create-manifest: needs: build if: github.event_name != 'pull_request' runs-on: ubuntu-latest permissions: packages: write steps: - uses: actions/checkout@v4 - name: Login GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Download all digests uses: actions/download-artifact@v4 with: pattern: digest-* path: digests merge-multiple: true - name: Create multi-arch manifest run: | docker buildx imagetools create \ --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \ $(cat digests/digest-amd64) \ $(cat digests/digest-arm64)