From c9c7876c87d9b834c11c4eec0fe0936ddec8b82d Mon Sep 17 00:00:00 2001 From: Jackson West Date: Mon, 6 Nov 2023 11:25:02 -0600 Subject: [PATCH] fixes PR body when opening PRs in other repos for minimal images (#1232) --- .../update_base_image_other_repos.sh | 43 +++++++++---------- pr-scripts/create_pr.sh | 2 +- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/eks-distro-base/update_base_image_other_repos.sh b/eks-distro-base/update_base_image_other_repos.sh index 66a8d43f0..69cb53b14 100755 --- a/eks-distro-base/update_base_image_other_repos.sh +++ b/eks-distro-base/update_base_image_other_repos.sh @@ -27,31 +27,31 @@ else ORIGIN_ORG=$REPO_OWNER fi -EXTRA_PR_BODY="" REPOS=(eks-distro eks-anywhere-build-tooling eks-anywhere) for repo in "${REPOS[@]}"; do ${SCRIPT_ROOT}/../pr-scripts/update_local_branch.sh "$repo" -done -while IFS=, read -r key -do - key=${key:2} # strip leading - space - while IFS=, read -r image + + EXTRA_PR_BODY="" + while IFS=, read -r key do - image=${image:2} # strip leading - space - BASE_IMAGE_TAG_FILE="$(echo ${image^^} | tr '-' '_')_TAG_FILE" + key=${key:2} # strip leading - space + while IFS=, read -r image + do + image=${image:2} # strip leading - space + BASE_IMAGE_TAG_FILE="$(echo ${image^^} | tr '-' '_')_TAG_FILE" - if [[ "$key" == "al2023" ]]; then - BASE_IMAGE_TAG_FILE="$(echo ${image^^} | tr '-' '_')_AL2023_TAG_FILE" - fi + if [[ "$key" == "al2023" ]]; then + BASE_IMAGE_TAG_FILE="$(echo ${image^^} | tr '-' '_')_AL2023_TAG_FILE" + fi + + IMAGE_TAG=$(yq e ".$key.\"$image\"" $SCRIPT_ROOT/../EKS_DISTRO_TAG_FILE.yaml) + # we will set the tag to null to trigger new builds. we dont want PRs being open setting + # tag file values to null + if [[ "${IMAGE_TAG}" = "null" ]]; then + continue + fi - IMAGE_TAG=$(yq e ".$key.\"$image\"" $SCRIPT_ROOT/../EKS_DISTRO_TAG_FILE.yaml) - # we will set the tag to null to trigger new builds. we dont want PRs being open setting - # tag file values to null - if [[ "${IMAGE_TAG}" = "null" ]]; then - continue - fi - for repo in "${REPOS[@]}"; do ${SCRIPT_ROOT}/../pr-scripts/update_image_tag.sh "$repo" '.*' $IMAGE_TAG $BASE_IMAGE_TAG_FILE if [ "$(git -C ${OTHER_CLONE_ROOT}/${ORIGIN_ORG}/${repo} status --porcelain -- $BASE_IMAGE_TAG_FILE | wc -l)" -gt 0 ]; then @@ -60,10 +60,9 @@ do EXTRA_PR_BODY+="\n${BASE_IMAGE_TAG_FILE}\nThe following yum packages were updated:\n\`\`\`bash\n${UPDATE_PACKAGES}\n\`\`\`\n" fi fi - done - done < <(yq e ".$key | keys" $SCRIPT_ROOT/../EKS_DISTRO_TAG_FILE.yaml) -done < <(yq e "keys" $SCRIPT_ROOT/../EKS_DISTRO_TAG_FILE.yaml) -for repo in "${REPOS[@]}"; do + done < <(yq e ".$key | keys" $SCRIPT_ROOT/../EKS_DISTRO_TAG_FILE.yaml) + done < <(yq e "keys" $SCRIPT_ROOT/../EKS_DISTRO_TAG_FILE.yaml) + ${SCRIPT_ROOT}/../pr-scripts/create_pr.sh "$repo" 'EKS_DISTRO*_TAG_FILE' "image-tag-update" "$EXTRA_PR_BODY" done diff --git a/pr-scripts/create_pr.sh b/pr-scripts/create_pr.sh index ce57c0c0a..9681dbd8f 100755 --- a/pr-scripts/create_pr.sh +++ b/pr-scripts/create_pr.sh @@ -77,7 +77,7 @@ else fi if [ -n "${EXTRA_PR_BODY}" ]; then - PR_BODY+="${EXTRA_PR_BODY}" + printf "${EXTRA_PR_BODY}" >> $PR_BODY_FILE fi # Adding this here to include the "do-not-merge/hold" label. Trying to use the gh client with the --label arg will not succeed