Skip to content

Commit

Permalink
Fix Comment Body (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
milldr authored Jun 30, 2023
1 parent 1fb52b3 commit 8e77f17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,16 @@ runs:
fi
printf "%s\n" '${{ steps.affected-stacks.outputs.affected }}' >affected-stacks.json
${GITHUB_ACTION_PATH}/scripts/spacelift-generate-pr-comment-body.sh $spacectl_deploy
# Check if comment body is empty (when all affected stacks have spacelift workspace disabled)
if [ -s comment-body.txt ]; then
echo "affected-stacks-enabled=true" >> $GITHUB_OUTPUT
else
echo "affected-stacks-enabled=false" >> $GITHUB_OUTPUT
fi
- name: Create PR Comment with Affected Stacks
uses: marocchino/sticky-pull-request-comment@f61b6cf21ef2fcc468f4345cdfcc9bda741d2343 # v2.6.2
if: ${{ steps.affected-stacks.outputs.has-affected-stacks == 'true' && inputs.trigger-method == 'comment' }}
if: ${{ steps.affected-stacks.outputs.has-affected-stacks == 'true' && inputs.trigger-method == 'comment' && fromJSON(steps.create-pr-comment-body.outputs.affected-stacks-enabled) }}
with:
header: atmos-affected-stacks
recreate: true
Expand Down
6 changes: 4 additions & 2 deletions scripts/spacelift-generate-pr-comment-body.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ for spacelift_stack in $(jq -r '.[].spacelift_stack' < "affected-stacks.json" |
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"
if [[ $stack_count -gt 0 ]]; then
sed -i "1 i\<details><summary>Spacelift Triggered Stacks ($stack_count)</summary>\n" comment-body.txt
printf "</details>\n" >> "comment-body.txt"
fi

0 comments on commit 8e77f17

Please sign in to comment.