Skip to content

Commit

Permalink
chore(ci): replace curl with gh wherever possible (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwrau authored Aug 19, 2024
1 parent 29d5834 commit 21a3257
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions .github/scripts/create-values-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function generateComment() {
sleep 2
done

echo "<!--helm-diff-->"
echo :robot: I have diffed this *beep* *boop*
echo ---
# shellcheck disable=SC2016
Expand All @@ -112,20 +113,15 @@ function createComment() {
local issue="$1"
local body="$2"

jq -cn --rawfile body <(echo "$body") '{body: $body}' |
curl --silent --fail-with-body \
-X POST \
-H 'Accept: application/vnd.github+json' \
-H "Authorization: token ${GITHUB_TOKEN}" \
"${GITHUB_API_REPO_URL}/issues/${issue}/comments" \
-d @-
gh pr comment "${issue}" -b "$body"
}

function updateComment() {
local issue="$1"
local commentId="$2"
local body="$3"

# needs to use the "manual" way, as `gh` doesn't support updating a specifc comment; https://github.com/cli/cli/issues/3613
jq -cn --rawfile body <(echo "$body") '{body: $body}' |
curl --silent --fail-with-body \
-X PATCH \
Expand All @@ -138,14 +134,7 @@ function updateComment() {
body=$(generateComment "$chart")

if [[ "$dryRun" == false ]]; then
existingCommentId="$(
curl --silent --fail-with-body \
-H 'Accept: application/vnd.github+json' \
-H "Authorization: token ${GITHUB_TOKEN}" \
"${GITHUB_API_REPO_URL}/issues/${issue}/comments" |
jq -r 'map(select(.body | contains(":robot: I have diffed this *beep* *boop*")))[0].id'
)"
if [[ "$existingCommentId" != null ]]; then
if existingCommentId="$(gh pr view "${issue}" --json comments | jq -er '.comments | map(select(.body | contains("<!--helm-diff-->")))[0].id')"; then
updateComment "$issue" "$existingCommentId" "$body"
else
createComment "$issue" "$body"
Expand Down

0 comments on commit 21a3257

Please sign in to comment.