From 1cf0a5fcd436505d89a8f40791fc8d3a57983866 Mon Sep 17 00:00:00 2001 From: Shankari Date: Thu, 14 Nov 2024 10:13:36 -0800 Subject: [PATCH] Switch to the build-push-action so that push to packages works https://github.com/EVerest/everest-demo/issues/78#issuecomment-2477073447 --- .github/workflows/build_and_push_csms.yml | 95 +++++++++++++++-------- 1 file changed, 64 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build_and_push_csms.yml b/.github/workflows/build_and_push_csms.yml index 45f81f8d..a1c726ed 100644 --- a/.github/workflows/build_and_push_csms.yml +++ b/.github/workflows/build_and_push_csms.yml @@ -25,6 +25,15 @@ jobs: - csms: maeve csms_repo: louisg1337/maeve-csms csms_branch: set_charging_profile + image_name: manager + context: ./maeve-csms/manager + host_namespace: ghcr.io/everest/everest-demo + - csms: maeve + csms_repo: louisg1337/maeve-csms + csms_branch: set_charging_profile + image_name: gateway + context: ./maeve-csms/gateway + host_namespace: ghcr.io/everest/everest-demo # - csms_dir: citrineos # csms_repo: https://github.com/citrineos/citrineos-core.git # csms_branch: feature/everest-demo @@ -85,28 +94,42 @@ jobs: pushd ${{ matrix.csms }}-csms bash ../everest-demo/${{ matrix.csms }}/apply-patches.sh - - name: Build using docker compose - id: build-using-docker-compose - shell: bash - run: | - source everest-demo/.env - echo "Using docker-compose instead of the build-and-push action since we don't have to duplicate the set of services in that case" - pushd ${{ matrix.csms }}-csms - docker compose build - - - name: List, tag and push newly built images - id: list-tag-and-push-newly-built-images - shell: bash - run: | - source everest-demo/.env - echo "Before retagging, image list is" - docker image list - # hardcoding the list of containers for now - echo "Retagging {{ $matrix.csms }}-csms-gateway:latest to " - docker tag ${{ matrix.csms }}-csms-gateway:latest ghcr.io/everest/everest-demo/${{ matrix.csms }}-csms-gateway:"${TAG}" - docker tag ${{ matrix.csms }}-csms-manager:latest ghcr.io/everest/everest-demo/${{ matrix.csms }}-csms-manager:"${TAG}" - echo "After retagging, image list is" - docker image list +# - name: Build using docker compose +# id: build-using-docker-compose +# shell: bash +# run: | +# source everest-demo/.env +# echo "Using docker-compose instead of the build-and-push action since we don't have to duplicate the set of services in that case" +# pushd ${{ matrix.csms }}-csms +# docker compose build +# +# - name: List, tag and push newly built images +# id: list-tag-and-push-newly-built-images +# shell: bash +# run: | +# source everest-demo/.env +# echo "Before retagging, image list is" +# docker image list +# # hardcoding the list of containers for now +# echo "Retagging {{ $matrix.csms }}-csms-gateway:latest to " +# docker tag ${{ matrix.csms }}-csms-gateway:latest ghcr.io/everest/everest-demo/${{ matrix.csms }}-csms-gateway:"${TAG}" +# docker tag ${{ matrix.csms }}-csms-manager:latest ghcr.io/everest/everest-demo/${{ matrix.csms }}-csms-manager:"${TAG}" +# echo "After retagging, image list is" +# docker image list +# + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Set Docker image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ matrix.host_namespace }}/${{ matrix.image_name }} + tags: | + type=semver,pattern={{version}},value=v${{ steps.docker-image-version-check.outputs.TAG }} - name: Log into GitHub container registry uses: docker/login-action@v3 @@ -115,12 +138,22 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Push the images as packages - id: push-the-images-as-packages - shell: bash - run: | - source everest-demo/.env - docker push ghcr.io/everest/everest-demo/${{ matrix.csms }}-csms-gateway:"${TAG}" - docker push ghcr.io/everest/everest-demo/${{ matrix.csms }}-csms-manager:"${TAG}" - - +# - name: Push the images as packages +# id: push-the-images-as-packages +# shell: bash +# run: | +# source everest-demo/.env +# docker push ghcr.io/everest/everest-demo/${{ matrix.csms }}-csms-gateway:"${TAG}" +# docker push ghcr.io/everest/everest-demo/${{ matrix.csms }}-csms-manager:"${TAG}" +# + + - name: Build and export to Docker + uses: docker/build-push-action@v6 + with: + load: true + context: ${{ matrix.context }} + push: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha,scope=${{ matrix.image_name }} + cache-to: type=gha,mode=max,scope=${{ matrix.image_name }}