-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update gh action with tweaks from https://github.com/pantheon-systems…
- Loading branch information
1 parent
feebb3d
commit 728bd2c
Showing
1 changed file
with
7 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 |