Skip to content

prettier test

prettier test #14

name: Prettier Auto-Format
on:
push:
branches:
- feat/add-prettier-format
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Check Out Repository
uses: actions/checkout@v2
- 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" >> $GITHUB_ENV
- name: Format Modified Files
if: ${{ env.MODIFIED_FILES != '' }}
run: |
modified_files=${{ env.MODIFIED_FILES }}
prettier --write $modified_files
- name: Commit Changes
if: ${{ env.MODIFIED_FILES != '' }}
run: |
git config --global user.name "Whisker17"
git config --global user.email "[email protected]"
git commit -m "Auto-format code with Prettier [skip ci]" --amend --no-edit
- name: Push Changes
if: ${{ env.MODIFIED_FILES != '' }}
run: |
branch_name=${{ github.ref }}
git push origin $branch_name --force-with-lease