Update GitHub Actions workflow to commit formatted code with Prettier #6
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: Format Code | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup bun | |
uses: oven-sh/setup-bun@v2 | |
- name: Install dependencies | |
run: bun install | |
- name: Format code | |
run: bun format | |
- name: Commit changes if any | |
env: | |
ACTIONS_PAT: ${{ secrets.FORMAT_PAT}} | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email 'github-actions@github.com' | |
git remote set-url origin https://x-access-token:${{ secrets.FORMAT_PAT }}@github.com/${{ github.repository }}.git | |
if [[ `git status --porcelain` ]]; then | |
git add . | |
git commit -m "Formatted code with Prettier" | |
git push | |
fi |