From 15e68aebc0b92fc7204b47e9f0a8c3af989d0a92 Mon Sep 17 00:00:00 2001 From: gabriel-farache Date: Fri, 11 Oct 2024 12:15:02 +0200 Subject: [PATCH] Fixing M2K Kfunc Signed-off-by: gabriel-farache --- .github/workflows/m2k-func.yaml | 16 +++------------- scripts/create_automated_m2k_kfunc_pr.sh | 6 ++++++ scripts/create_or_update_automated_pr.sh | 6 ++++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/m2k-func.yaml b/.github/workflows/m2k-func.yaml index 5f4c8d76..daf81910 100644 --- a/.github/workflows/m2k-func.yaml +++ b/.github/workflows/m2k-func.yaml @@ -86,24 +86,14 @@ jobs: PR_OR_COMMIT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" fi - git config --global user.email "${{ github.event.head_commit.author.email || 'parodos@redhat.com' }}" - git config --global user.name ${{ github.event.head_commit.author.name || github.triggering_actor }} - gh repo clone $WF_CONFIG_REPO config-repo - cd config-repo - git switch -c m2k-kfunc-autopr-$RANDOM - - ./hack/bump_chart_version.sh move2kube --bump-tag-version - - yq --inplace '.kfunction.image="quay.io/orchestrator/serverless-workflow-m2k-kfunc:${{ github.sha }}"' charts/move2kube/values.yaml - cd .. - echo "Running create_or_update_automated_pr script" sh scripts/create_or_update_automated_pr.sh $WF_CONFIG_REPO \ ${{ inputs.workflow_id }} \ ${PR_OR_COMMIT_URL} \ - config-repo/charts/move2kube/values.yaml \ + "yq --inplace '.kfunction.image=\"quay.io/orchestrator/serverless-workflow-m2k-kfunc:'\"${GITHUB_SHA}\"'\"' charts/move2kube/values.yaml" \ scripts/create_automated_m2k_kfunc_pr.sh \ ${{ github.event.head_commit.author.email || 'parodos@redhat.com' }} \ ${{ github.event.head_commit.author.name || github.triggering_actor }} \ $WORKDIR \ ${{ env.GH_TOKEN }} \ - $WF_CONFIG_REPO + $WF_CONFIG_REPO \ + ${{ github.sha }} diff --git a/scripts/create_automated_m2k_kfunc_pr.sh b/scripts/create_automated_m2k_kfunc_pr.sh index 784cf3fe..4d964030 100644 --- a/scripts/create_automated_m2k_kfunc_pr.sh +++ b/scripts/create_automated_m2k_kfunc_pr.sh @@ -6,13 +6,19 @@ WORKFLOW_ID=$4 PR_OR_COMMIT_URL=$5 GH_TOKEN=$6 WF_CONFIG_REPO=$7 +GITHUB_SHA=$8 +TIMESTAMP=$(date +%s) git config --global user.email "${USER_EMAIL}" git config --global user.name "${USER_NAME}" +gh repo clone "${WF_CONFIG_REPO}" config-repo cd config-repo || exit +git switch -c "${WORKFLOW_ID}"-autopr-"${TIMESTAMP}" +./hack/bump_chart_version.sh "${WORKFLOW_ID}" --bump-tag-version mkdir -p charts/"${WORKFLOW_ID}"/templates cp "${WORKDIR}"/"${WORKFLOW_ID}"/manifests/* charts/"${WORKFLOW_ID}"/templates +yq --inplace '.kfunction.image="quay.io/orchestrator/serverless-workflow-m2k-kfunc:'"${GITHUB_SHA}"'"' charts/move2kube/values.yaml git add -A git commit -m "(m2k-kfunc) Automated PR" diff --git a/scripts/create_or_update_automated_pr.sh b/scripts/create_or_update_automated_pr.sh index 1352f530..7507bf19 100644 --- a/scripts/create_or_update_automated_pr.sh +++ b/scripts/create_or_update_automated_pr.sh @@ -12,6 +12,7 @@ USER_NAME=$7 WORKDIR=$8 GH_TOKEN=$9 WF_CONFIG_REPO=${10} +GITHUB_SHA=${11} # Get all open PRs for the repository prs=$(gh pr list --repo "${REPO}" --json number --jq '.[].number') @@ -50,7 +51,7 @@ for pr in $prs; do # Create the new file cp "${WORKDIR}"/"${WORKFLOW_ID}"/manifests/* charts/"${WORKFLOW_ID}"/templates || exit 1 if [ "${INPUT_VALUES_FILEPATH}" != "" ]; then - cp "${INPUT_VALUES_FILEPATH}" "charts/${WORKFLOW_ID}/values.yaml" || exit 1 + eval "${INPUT_VALUES_FILEPATH}" || exit 1 fi git add -A @@ -72,4 +73,5 @@ sh "${CREATE_PR_SCRIPT}" "${USER_EMAIL}" \ "${WORKFLOW_ID}" \ "${PR_OR_COMMIT_URL}" \ "${GH_TOKEN}" \ - "${WF_CONFIG_REPO}" + "${WF_CONFIG_REPO}" \ + "${GITHUB_SHA}" \ No newline at end of file