Cofigure Prettier CI #8
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
name: Run Prettier | |
on: | |
push: | |
branches: [master] | |
jobs: | |
prettier: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Capture original commit message | |
id: capture_message | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV | |
- name: Run Prettier | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
npx prettier --write . && git add . | |
- name: Commit changes | |
run: | | |
git commit -m "${{ env.COMMIT_MESSAGE }} (Prettified)" | |
- name: Push changes | |
uses: ad-m/github-push-action@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |