From a607d44859b4f2fe98e8c2ae39234e0e5a8ccbd8 Mon Sep 17 00:00:00 2001 From: Roy Golan Date: Mon, 15 Jul 2024 17:57:50 +0300 Subject: [PATCH] Pass the full github sha to the make targets in github actions The Makefile default is to use a short 8 chars of the revision, while the github action is relying on the full github version using the {{ github.sha }} context variable, which is available every where. We could potentially change the short sha in the makefile, but it is convenient for developers, hence will leave this untouched for now. Signed-off-by: Roy Golan --- .github/workflows/main.yml | 3 +++ Makefile | 2 +- scripts/gen_manifests.sh | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2c99438b..d94d647b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,6 +41,7 @@ jobs: run: | make WORKFLOW_ID=${{ inputs.workflow_id }} \ APPLICATION_ID=${{ inputs.application_id }} \ + IMAGE_TAG=${{ github.sha }} \ GIT_TOKEN=${{ env.GH_TOKEN }} \ REGISTRY_REPO=${{ env.REGISTRY_REPO }} \ REGISTRY_USERNAME=${{ secrets.NEW_QUAY_USERNAME }} \ @@ -81,6 +82,7 @@ jobs: run: | make WORKFLOW_ID=${{ inputs.workflow_id }} \ APPLICATION_ID=${{ inputs.application_id }} \ + IMAGE_TAG=${{ github.sha }} \ GIT_TOKEN=${{ env.GH_TOKEN }} \ REGISTRY_REPO=${{ env.REGISTRY_REPO }} \ REGISTRY_USERNAME=${{ secrets.NEW_QUAY_USERNAME }} \ @@ -98,6 +100,7 @@ jobs: WORKDIR=${{ runner.temp }}/serverless-workflows make WORKFLOW_ID=${{ inputs.workflow_id }} \ WORKDIR=${WORKDIR} \ + IMAGE_TAG=${{ github.sha }} \ APPLICATION_ID=${{ inputs.application_id }} \ PR_OR_COMMIT_URL=${PR_OR_COMMIT_URL} \ gen-manifests diff --git a/Makefile b/Makefile index d1fd25d7..1634f219 100644 --- a/Makefile +++ b/Makefile @@ -175,7 +175,7 @@ save-oci: build-image gen-manifests: prepare-workdir cd $(WORKDIR) @$(CONTAINER_ENGINE) run --rm -v $(WORKDIR):/workdir:Z -w /workdir \ - $(LINUX_IMAGE) /bin/bash -c "ENABLE_PERSISTENCE=$(ENABLE_PERSISTENCE) ${SCRIPTS_DIR}/gen_manifests.sh $(WORKFLOW_ID)" + $(LINUX_IMAGE) /bin/bash -c "ENABLE_PERSISTENCE=$(ENABLE_PERSISTENCE) WORKFLOW_IMAGE_TAG=$(IMAGE_TAG) ${SCRIPTS_DIR}/gen_manifests.sh $(WORKFLOW_ID)" @echo "Manifests are available in workdir $(WORKDIR)/$(WORKFLOW_ID)/manifests" # Target: push-manifests diff --git a/scripts/gen_manifests.sh b/scripts/gen_manifests.sh index 4b30bcc3..0a8375fd 100755 --- a/scripts/gen_manifests.sh +++ b/scripts/gen_manifests.sh @@ -1,6 +1,10 @@ #!/bin/bash WORKFLOW_FOLDER=$1 +WORKFLOW_IMAGE_REGISTRY="${WORKFLOW_IMAGE_REGISTRY:-quay.io}" +WORKFLOW_IMAGE_NAMESPACE="${WORKFLOW_IMAGE_NAMESPACE:-orchestrator}" +WORKFLOW_IMAGE_REPO="${WORKFLOW_IMAGE_REPO:-serverless-workflow-${WORKFLOW_FOLDER}}" +WORKFLOW_IMAGE_TAG="${WORKFLOW_IMAGE_TAG:-latest}" if [ ! -f kn ]; then echo "Installing kn-workflow CLI" @@ -43,7 +47,7 @@ fi SONATAFLOW_CR=manifests/01-sonataflow_${workflow_id}.yaml yq --inplace eval '.metadata.annotations["sonataflow.org/profile"] = "prod"' "${SONATAFLOW_CR}" -yq --inplace ".spec.podTemplate.container.image=\"quay.io/orchestrator/serverless-workflow-${WORKFLOW_FOLDER}:latest\"" "${SONATAFLOW_CR}" +yq --inplace ".spec.podTemplate.container.image=\"${WORKFLOW_IMAGE_REGISTRY}/${WORKFLOW_IMAGE_NAMESPACE}/${WORKFLOW_IMAGE_REPO}:${WORKFLOW_IMAGE_TAG}\"" "${SONATAFLOW_CR}" if [ "${ENABLE_PERSISTENCE}" = true ]; then yq --inplace ".spec |= (