Skip to content

Commit

Permalink
TASK: Update comments when we have new recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
markusguenther committed Jan 25, 2024
1 parent 1740397 commit fc1e086
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Build/comment-acceptance-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ function generateCommentBody() {
done

# Construct the comment with the latest acceptance test recordings
commentBody="🎥 **End-to-End Test Recordings**\n\n$videoRecordingsLinks\n\nThese videos demonstrate the end-to-end tests for the changes in this pull request."
# Construct the comment with the latest acceptance test recordings
if [ -n "$videoRecordingsLinks" ]; then
commentBody="🎥 **End-to-End Test Recordings**\n\n$videoRecordingsLinks\n\nThese videos demonstrate the end-to-end tests for the changes in this pull request."
else
# empty comment body to prevent a comment without recordings
commentBody=""
fi
}

# Check if a comment with recordings already exists
Expand All @@ -37,10 +43,13 @@ function createComment() {

# If a comment with recordings exists, update the existing comment
function updateComment() {
# Todo: The gh cli does not support editing comments yet, so we have to use the GitHub API directly
# Note: The gh cli does not support editing comments yet, so we have to use the GitHub API directly
echo "Updating existing comment..."
comment_uri=$(echo "$existing_comment" | jq -r ".url")
gh pr comment $comment_uri --body "$(printf "$commentBody")"
commentUri=$(echo "$existingComment" | jq -r ".url")
commentId=$(echo "$commentUri" | awk -F'#issuecomment-' '{print $2}')
curl -s -H "Authorization: token $GH_TOKEN" \
-X PATCH -d "{\"body\":\"$(printf "$commentBody")\"}" \
"https://api.github.com/repos/neos/neos-ui/issues/comments/$commentId"
}

jobIds=$1
Expand All @@ -49,8 +58,7 @@ generateCommentBody
getExistingComment

if [ -n "$existingComment" ]; then
# @todo: use updateComment once the gh cli supports editing comments or we use the Github API directly
createComment
updateComment
else
createComment
fi
Expand Down

0 comments on commit fc1e086

Please sign in to comment.