From 7ddcb31c5754889804994949721f5c6b6bb216cd Mon Sep 17 00:00:00 2001 From: Niko Kurtti Date: Fri, 22 Nov 2024 15:41:36 +0200 Subject: [PATCH] Hotfix builds on publish to match lower env builds --- .github/workflows/publish-release.yml | 40 +++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 443566e7cd0..c40a17314f2 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -48,12 +48,29 @@ jobs: - name: Get list of services id: get-services run: | - services=$(grep "^ [^ ]" docker-compose.yml | grep -v '#' | awk -F: '{print $1}' | sed -e 's/^ *//') + services=$(grep "^ [^ ]" docker-compose.yml | grep -v base| grep -v '#' | awk -F: '{print $1}' | sed -e 's/^ *//') services_json=$(echo $services | tr '\n' ',' | sed 's/,$//' | jq -R 'split(" ")' | tr -d '\n') # Set the list of service names as an output variable echo "services=$services_json" >> $GITHUB_OUTPUT echo "services=$services_json" + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push base image + uses: docker/build-push-action@v6 + with: + file: packages/Dockerfile.base + context: . + push: true + tags: | + opencrvs/ocrvs-base:${{ steps.set-version.outputs.version }} + cache-from: type=registry,ref=opencrvs/ocrvs-base:${{ steps.set-version.outputs.version }} + cache-to: type=inline + outputs: services: ${{ steps.get-services.outputs.services }} version: ${{ steps.set-version.outputs.version }} @@ -61,6 +78,7 @@ jobs: build: needs: base strategy: + fail-fast: false matrix: service: ${{ fromJSON(needs.base.outputs.services) }} runs-on: ubuntu-22.04 @@ -74,17 +92,23 @@ jobs: if: github.event_name == 'push' - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build ${{ matrix.service }} - run: | - echo ${{ matrix.service }} - export VERSION=${{ github.event.inputs.release_version }} - docker compose build ${{ matrix.service }} - docker compose push ${{ matrix.service }} + - name: Build and push + uses: docker/build-push-action@v6 + with: + file: packages/${{ matrix.service }}/Dockerfile + build-args: | + VERSION=${{ needs.base.outputs.version }} + push: true + context: . + tags: | + opencrvs/ocrvs-${{ matrix.service }}:${{ needs.base.outputs.version }} + cache-from: type=registry,ref=opencrvs/ocrvs-${{ matrix.service }}:${{ needs.base.outputs.version}} + cache-to: type=inline security-scans: needs: [base, build]