forked from w3f/Grant-Milestone-Delivery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 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 |
---|---|---|
|
@@ -13,5 +13,34 @@ jobs: | |
- name: Check Out Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Prettier Auto-Format | ||
run: docker run --rm -v $PWD:/app -w /app prettier/prettier:latest --write . | ||
- name: Install Prettier | ||
run: npm install prettier --global | ||
|
||
- name: Get Modified Files | ||
id: modified-files | ||
run: | | ||
modified_files=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }}) | ||
echo "$modified_files" > modified_files.txt | ||
- name: Read Modified Files | ||
id: read-env | ||
run: echo "MODIFIED_FILES=$(cat modified_files.txt)" >> $GITHUB_ENV | ||
|
||
- name: Format Modified Files | ||
if: ${{ env.MODIFIED_FILES != '' }} | ||
run: | | ||
prettier --write ${{ env.MODIFIED_FILES }} | ||
- name: Commit Changes | ||
if: ${{ env.MODIFIED_FILES != '' }} | ||
run: | | ||
git config --global user.name "Your GitHub Username" | ||
git config --global user.email "[email protected]" | ||
git add . | ||
git commit -m "Auto-format code with Prettier [skip ci]" | ||
- name: Push Changes | ||
if: ${{ env.MODIFIED_FILES != '' }} | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
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