Skip to content

Commit

Permalink
wrap comments in details block (#20)
Browse files Browse the repository at this point in the history
* wrap comments in details block
* update body logic
  • Loading branch information
mcalhoun authored Jun 21, 2023
1 parent fb8aa1d commit 1fb52b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ runs:
spacectl_deploy="true"
fi
printf "%s\n" '${{ steps.affected-stacks.outputs.affected }}' >affected-stacks.json
body=$(${GITHUB_ACTION_PATH}/scripts/spacelift-generate-pr-comment-body.sh $spacectl_deploy)
printf "body=%s" "$body" >>$GITHUB_OUTPUT
${GITHUB_ACTION_PATH}/scripts/spacelift-generate-pr-comment-body.sh $spacectl_deploy
- name: Create PR Comment with Affected Stacks
uses: marocchino/sticky-pull-request-comment@f61b6cf21ef2fcc468f4345cdfcc9bda741d2343 # v2.6.2
Expand Down
6 changes: 6 additions & 0 deletions scripts/spacelift-generate-pr-comment-body.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ if [ "$1" = "true" ]; then
fi

# Use jq to extract the spacelift_stack values and iterate through them
stack_count=0
for spacelift_stack in $(jq -r '.[].spacelift_stack' < "affected-stacks.json" | grep -v null); do
printf "/spacelift %s %s\n" "$spacectl_command" "$spacelift_stack" >> "comment-body.txt"
stack_count=$((stack_count+1))
done

# Wrap the contents in a collapsible details block
sed -i "1 i\<details><summary>Spacelift Triggered Stacks ($stack_count)</summary>" comment-body.txt
printf "</details>\n" >> "comment-body.txt"

0 comments on commit 1fb52b3

Please sign in to comment.