From 98374a50773e6adc38ef64f97eb0f85addfae3ec Mon Sep 17 00:00:00 2001 From: Reza Rajan <28660160+rezarajan@users.noreply.github.com> Date: Tue, 18 Nov 2025 01:34:58 -0400 Subject: [PATCH] feat(gh-actions): include multi-platform OCI image build - ignore workflow paths which only modify the oci image --- .github/workflows/ci.yaml | 4 ++ .github/workflows/oci-image.yaml | 63 +++++++++++++++++++++++--------- .github/workflows/release.yml | 5 +++ 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 59bef884..fadb3569 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,6 +2,10 @@ name: CI on: push: + paths-ignore: + - .github/workflows/oci.yml + - docker/** + - Dockerfile workflow_dispatch: inputs: upload_artifacts: diff --git a/.github/workflows/oci-image.yaml b/.github/workflows/oci-image.yaml index 25cbf473..e2532fac 100644 --- a/.github/workflows/oci-image.yaml +++ b/.github/workflows/oci-image.yaml @@ -2,40 +2,67 @@ name: OCI on: push: + branches: + - main release: types: - published +env: + REGISTRY_IMAGE: ${{ vars.REGISTRY_IMAGE }} + jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm64 steps: - name: 📥 Checkout repository uses: actions/checkout@v4 + - name: 🧰 Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: 🚀 Build the image + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Prepare platform run: | - docker compose build --build-arg GIT_REVISION=$(git rev-parse @) - - name: 📤 Push the image (edge) + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Build and push edge image if: github.ref == 'refs/heads/main' - run: | - image=ghcr.io/blockfrost/blockfrost-platform - docker push $image:edge - - name: 📤 Push the image (version tag) + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: ${{ matrix.platform }} + push: true + tags: ${{ env.REGISTRY_IMAGE }}:edge + build-args: | + GIT_REVISION=${{ github.sha }} + + - name: Build and push release version if: github.event_name == 'release' && github.event.action == 'published' - run: | - image=ghcr.io/blockfrost/blockfrost-platform - docker push $image:edge - docker tag $image:edge $image:${{ github.event.release.tag_name }} - docker push $image:${{ github.event.release.tag_name }} - - name: 📤 Push the image (latest tag) - if: github.event_name == 'release' && github.event.action == 'published' && !github.event.release.prerelease - run: | - image=ghcr.io/blockfrost/blockfrost-platform - docker tag $image:edge $image:latest - docker push $image:latest + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: ${{ matrix.platform }} + push: true + tags: | + ${{ env.REGISTRY_IMAGE }}:edge + ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }} + ${{ github.event.release.prerelease && '' || format('{0}:latest', env.REGISTRY_IMAGE) }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 650eb7d1..b9d9c5c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,11 @@ name: Release on: + push: + paths-ignore: + - .github/workflows/oci.yml + - docker/** + - Dockerfile release: types: - published