Skip to content

Commit

Permalink
fix(ci): allow running on forks (teutonet#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwrau authored and SyeKlu committed May 13, 2024
1 parent 39e4fbf commit b862af5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
24 changes: 14 additions & 10 deletions .github/scripts/create-values-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,18 @@ function createComment() {
-d @-
}

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

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

body=$(generateComment "$chart")
Expand All @@ -140,12 +143,13 @@ if [[ "$dryRun" == false ]]; then
-H 'Accept: application/vnd.github+json' \
-H "Authorization: token ${GITHUB_TOKEN}" \
"${GITHUB_API_REPO_URL}/issues/${issue}/comments" |
jq '. | map(select(.body | contains(":robot: I have diffed this *beep* *boop*")))[0].id'
jq -er 'map(select(.body | contains(":robot: I have diffed this *beep* *boop*")))[0].id'
)"
if [[ "$existingCommentId" != null ]]; then
deleteComment "$issue" "$existingCommentId"
updateComment "$issue" "$existingCommentId" "$body"
else
createComment "$issue" "$body"
fi
createComment "$issue" "$body"
else
echo "$body"
fi
2 changes: 1 addition & 1 deletion .github/workflows/label-pullrequest.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Label Chart Pull Request

on:
pull_request:
pull_request_target:
paths:
- charts/**
types:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-comment-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ concurrency:
cancel-in-progress: true

on:
pull_request:
pull_request_target:
paths:
- charts/**
branches-ignore:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-pullrequest.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Validate and label Pull Request

on:
pull_request:
pull_request_target:
types:
- opened
- edited
Expand Down

0 comments on commit b862af5

Please sign in to comment.