From 5f30ef334bcde6135fa22a1aa565133dc0393284 Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 30 Jun 2021 15:56:57 +0300 Subject: [PATCH 1/2] ci: sidecar images updates will be also created for latest bugfix branch Signed-off-by: Mykhailo Kuznietsov --- .github/workflows/sidecar-check.yml | 3 ++- .../check_sidecar_image_digests.sh | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sidecar-check.yml b/.github/workflows/sidecar-check.yml index d635f932e..3322ea23e 100644 --- a/.github/workflows/sidecar-check.yml +++ b/.github/workflows/sidecar-check.yml @@ -72,4 +72,5 @@ jobs: git config --global user.name "Mykhailo Kuznietsov" git config --global user.email "mkuznets@redhat.com" export GITHUB_TOKEN=${{ secrets.CHE_BOT_GITHUB_TOKEN }} - ./arbitrary-users-patch/check_sidecar_image_digests.sh + BUGFIX_BRANCH="$(git branch -a | grep "remotes/origin/7.*" | cut -d '/' -f 3 | sort --version-sort | tail -n1)" + ./arbitrary-users-patch/check_sidecar_image_digests.sh --bugfix-branch ${BUGFIX_BRANCH} diff --git a/arbitrary-users-patch/check_sidecar_image_digests.sh b/arbitrary-users-patch/check_sidecar_image_digests.sh index 6176c75dc..4ffb335dc 100755 --- a/arbitrary-users-patch/check_sidecar_image_digests.sh +++ b/arbitrary-users-patch/check_sidecar_image_digests.sh @@ -15,9 +15,11 @@ set -e NO_OP="false" +BUGFIX_BRANCH="" while [[ "$#" -gt 0 ]]; do case $1 in '-n'|'--no-op') NO_OP="true"; shift 0;; + '-bb'|'--bugfix-branch') BUGFIX_BRANCH=$2; shift 1;; esac shift 1 done @@ -36,18 +38,27 @@ createPR() { set +e PR_BRANCH="$1" - COMMIT_MSG="[update] Update digests in base_images" + COMMIT_MSG="chore: Update digests in base_images" # commit change into branch git add "${SCRIPT_DIR}"/base_images git commit -sm "${COMMIT_MSG}" git branch "${PR_BRANCH}" - git checkout "${PR_BRANCH}" + git checkout "${PR_BRANCH}" git pull origin "${PR_BRANCH}" git push origin "${PR_BRANCH}" lastCommitComment="$(git log -1 --pretty=%B)" + hub pull-request -f -m "${lastCommitComment}" -b "${MAIN_BRANCH}" -h "${PR_BRANCH}" + + if [[ ! -z ${BUGFIX_BRANCH} ]]; then + lastCommitId="$(git log --format=\"%H\" -n 1)" + git checkout ${BUGFIX_BRANCH} + git branch "${PR_BRANCH}-bugfix-branch" + git checkout -b "${PR_BRANCH}-bugfix-branch" + hub pull-request -f -m "${lastCommitComment}" -b "${MAIN_BRANCH}" -h "${PR_BRANCH}-bugfix-branch" + fi set -e } @@ -77,6 +88,7 @@ if [[ $(git diff --exit-code "${SCRIPT_DIR}"/base_images) ]]; then else echo "[INFO] Changes detected, generating PR with new digests" createPR "new-base-image-digests" + create fi else echo "[INFO] No changes detected for digests, do nothing" From 739e1396cee469856fa8bf16b0245378b7e1049d Mon Sep 17 00:00:00 2001 From: Mykhailo Kuznietsov Date: Wed, 30 Jun 2021 16:04:43 +0300 Subject: [PATCH 2/2] fixup! ci: sidecar images updates will be also created for latest bugfix branch --- arbitrary-users-patch/check_sidecar_image_digests.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arbitrary-users-patch/check_sidecar_image_digests.sh b/arbitrary-users-patch/check_sidecar_image_digests.sh index 4ffb335dc..d7ad9253b 100755 --- a/arbitrary-users-patch/check_sidecar_image_digests.sh +++ b/arbitrary-users-patch/check_sidecar_image_digests.sh @@ -52,11 +52,12 @@ createPR() { hub pull-request -f -m "${lastCommitComment}" -b "${MAIN_BRANCH}" -h "${PR_BRANCH}" - if [[ ! -z ${BUGFIX_BRANCH} ]]; then + if [[ -n ${BUGFIX_BRANCH} ]]; then lastCommitId="$(git log --format=\"%H\" -n 1)" - git checkout ${BUGFIX_BRANCH} + git checkout "${BUGFIX_BRANCH}" git branch "${PR_BRANCH}-bugfix-branch" - git checkout -b "${PR_BRANCH}-bugfix-branch" + git checkout "${PR_BRANCH}-bugfix-branch" + git cherry-pick "${lastCommitId}" hub pull-request -f -m "${lastCommitComment}" -b "${MAIN_BRANCH}" -h "${PR_BRANCH}-bugfix-branch" fi set -e