Skip to content

Commit

Permalink
update gh action with tweaks from https://github.com/pantheon-systems…
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence committed Aug 26, 2024
1 parent feebb3d commit 728bd2c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ jobs:
echo "Fixing the following files:"
echo "$CHANGED_FILES"
echo "$CHANGED_FILES" | xargs npx prettier --write
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
# Join the filenames into a single line with space separation.
JOINED_FILES=$(echo $CHANGED_FILES | tr '\n' ' ')
echo "CHANGED_FILES=$JOINED_FILES" >> $GITHUB_ENV
else
echo "No files to format"
fi
Expand All @@ -52,7 +54,8 @@ jobs:
git config user.email "[email protected]"
git add .
git commit -m "Apply Prettier formatting"
git push
git push origin HEAD:${{ github.head_ref }}
DIFF_OUTPUT=$(git diff HEAD~1 HEAD)
echo "DIFF_OUTPUT<<EOF" >> $GITHUB_ENV
echo "$DIFF_OUTPUT" >> $GITHUB_ENV
Expand All @@ -65,7 +68,8 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
if [ -n "${{ env.DIFF_OUTPUT }}" ]; then
gh pr comment ${{ github.event.pull_request.number }} --body "$(echo -e "Hi from your friendly robot! 🤖\n\nI've applied Prettier formatting to the following files:\n\n${{ env.CHANGED_FILES }}\n\nThe full diff is below:\n\n<details>\n<summary>Click to expand</summary>\n\n\`\`\`diff\n$DIFF_OUTPUT\n\`\`\`\n</details>")"
CURRENT_COMMIT=$(git rev-parse --short HEAD)
gh pr comment ${{ github.event.pull_request.number }} --body "$(echo -e "Hi from your friendly robot! 🤖\n\nI've applied Prettier formatting to the following files in $CURRENT_COMMIT:\n\n\`${{ env.CHANGED_FILES }}\`\n\nThe full diff is below. Please review the changes.\n\n<details>\n<summary>Click to expand</summary>\n\n\`\`\`diff\n$DIFF_OUTPUT\n\`\`\`\n</details>")"
else
echo "No Prettier changes"
fi

0 comments on commit 728bd2c

Please sign in to comment.