From ca2178462fc6248252c7abf319655df0024a7f58 Mon Sep 17 00:00:00 2001 From: Steven Quan Date: Thu, 21 Mar 2024 16:47:29 +0000 Subject: [PATCH 1/6] fix(TECH): ecr scan results fix --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9705431..45e6ad7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,12 +6,13 @@ ARG BASH_VERSION="5" ARG AWS_CLI_VERSION="2" ARG JQ_VERSION="1" ARG CURL_VERSION="8" +ARG GIT_VERSION="2" WORKDIR /scripts RUN apk update --no-cache; \ apk upgrade --no-cache; \ - apk add --no-cache bash~=${BASH_VERSION} aws-cli~=${AWS_CLI_VERSION} jq~=${JQ_VERSION} curl~=${CURL_VERSION} ; \ + apk add --no-cache bash~=${BASH_VERSION} aws-cli~=${AWS_CLI_VERSION} jq~=${JQ_VERSION} git~=${GIT_VERSION} ; \ rm -rf /var/cache/apk/* ENV LOG_LEVEL "INFO" From 6f854a3d2c256428c89ba85e7cb1e6cd032e2aae Mon Sep 17 00:00:00 2001 From: Steven Quan Date: Thu, 21 Mar 2024 16:49:24 +0000 Subject: [PATCH 2/6] missing curl --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 45e6ad7..0a9f8e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /scripts RUN apk update --no-cache; \ apk upgrade --no-cache; \ - apk add --no-cache bash~=${BASH_VERSION} aws-cli~=${AWS_CLI_VERSION} jq~=${JQ_VERSION} git~=${GIT_VERSION} ; \ + apk add --no-cache bash~=${BASH_VERSION} aws-cli~=${AWS_CLI_VERSION} jq~=${JQ_VERSION} curl~=${CURL_VERSION} git~=${GIT_VERSION}; \ rm -rf /var/cache/apk/* ENV LOG_LEVEL "INFO" From c4d88a772c7b0fcb0f7579329cadb30cbc6bcfb7 Mon Sep 17 00:00:00 2001 From: Steven Quan Date: Thu, 21 Mar 2024 16:50:00 +0000 Subject: [PATCH 3/6] fixing whitespace --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0a9f8e9..e48f2b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /scripts RUN apk update --no-cache; \ apk upgrade --no-cache; \ - apk add --no-cache bash~=${BASH_VERSION} aws-cli~=${AWS_CLI_VERSION} jq~=${JQ_VERSION} curl~=${CURL_VERSION} git~=${GIT_VERSION}; \ + apk add --no-cache bash~=${BASH_VERSION} aws-cli~=${AWS_CLI_VERSION} jq~=${JQ_VERSION} curl~=${CURL_VERSION} git~=${GIT_VERSION}; \ rm -rf /var/cache/apk/* ENV LOG_LEVEL "INFO" From b3c2e35950446a51ec5a396807a70e44dc29a827 Mon Sep 17 00:00:00 2001 From: Abdalaziz Mohamed <89922655+amohamedhey@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:44:22 +0100 Subject: [PATCH 4/6] Update Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index e48f2b9..3c51ee5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ ARG AWS_CLI_VERSION="2" ARG JQ_VERSION="1" ARG CURL_VERSION="8" ARG GIT_VERSION="2" +ARG GITHUB_CLI_VERSION="2" WORKDIR /scripts From 314cd774824c4ba920ae04d73d4d452ca6a0589e Mon Sep 17 00:00:00 2001 From: Abdalaziz Mohamed <89922655+amohamedhey@users.noreply.github.com> Date: Fri, 22 Mar 2024 10:44:30 +0100 Subject: [PATCH 5/6] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3c51ee5..c9472f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ WORKDIR /scripts RUN apk update --no-cache; \ apk upgrade --no-cache; \ - apk add --no-cache bash~=${BASH_VERSION} aws-cli~=${AWS_CLI_VERSION} jq~=${JQ_VERSION} curl~=${CURL_VERSION} git~=${GIT_VERSION}; \ + apk add --no-cache bash~=${BASH_VERSION} aws-cli~=${AWS_CLI_VERSION} jq~=${JQ_VERSION} curl~=${CURL_VERSION} git~=${GIT_VERSION} github-cli~=${GITHUB_CLI_VERSION}; \ rm -rf /var/cache/apk/* ENV LOG_LEVEL "INFO" From c3ff65a0b0c6c5397d3e6c448ebd5fb4ae0f9d8d Mon Sep 17 00:00:00 2001 From: Youssef Dhraief Date: Fri, 22 Mar 2024 10:46:02 +0100 Subject: [PATCH 6/6] fix: fixed some issues with script and dependencies --- scripts/gh-utils.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/gh-utils.sh b/scripts/gh-utils.sh index 036ff1e..d30eff8 100644 --- a/scripts/gh-utils.sh +++ b/scripts/gh-utils.sh @@ -1,5 +1,31 @@ #!/usr/bin/env bash +function get_formatted_comment_id() { + _comment_id="${1}" + echo "" +} + +# The `delete_previous_comments` function deletes comments by their ids from pull requests. +function delete_previous_comments() { + _repo_org="${1}" + _repo_name="${2}" + _pr_number="${3}" + + _nextPage="1" + while [[ "${_nextPage}" != "0" ]]; do + _comments="$(gh api "/repos/${_repo_org}/${_repo_name}/issues/${_pr_number}/comments?direction=asc&per_page=20&page=${_nextPage}")" + if [[ "$(echo "${_comments}" | jq '.|length')" == 0 ]]; then + _nextPage="0" + else + _nextPage="$((_nextPage + 1))" + fi + while read -r _previous_comment_id; do + log_out "Deleting previous comment with ID: ${_previous_comment_id}" + gh api "/repos/${_repo_org}/${_repo_name}/issues/comments/${_previous_comment_id}" -X DELETE >/dev/null + done < <(echo "${_comments}" | jq ".[] | select(.body|startswith(\"$(get_formatted_comment_id "${_comment_id}")\")) | .id") + done +} + # The `comment_on_pull_request` function pushes a comment to a pull request. function comment_on_pull_request() { _repo_org="${1}"