Skip to content

Commit

Permalink
fix(TECH): ecr scan results fix (#2)
Browse files Browse the repository at this point in the history
* fix(TECH): ecr scan results fix

* missing curl

* fixing whitespace

* Update Dockerfile

* Update Dockerfile

* fix: fixed some issues with script and dependencies

---------

Co-authored-by: Abdalaziz Mohamed <89922655+amohamedhey@users.noreply.github.com>
Co-authored-by: Youssef Dhraief <dhraief.youssef@gmail.com>
  • Loading branch information
3 people authored Mar 22, 2024
1 parent 67e6b0b commit 84a7e97
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ ARG BASH_VERSION="5"
ARG AWS_CLI_VERSION="2"
ARG JQ_VERSION="1"
ARG CURL_VERSION="8"
ARG GIT_VERSION="2"
ARG GITHUB_CLI_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} curl~=${CURL_VERSION} git~=${GIT_VERSION} github-cli~=${GITHUB_CLI_VERSION}; \
rm -rf /var/cache/apk/*

ENV LOG_LEVEL "INFO"
Expand Down
26 changes: 26 additions & 0 deletions scripts/gh-utils.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
#!/usr/bin/env bash

function get_formatted_comment_id() {
_comment_id="${1}"
echo "<!-- comment-id:${_comment_id} -->"
}

# 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}"
Expand Down

0 comments on commit 84a7e97

Please sign in to comment.