Skip to content

Update GitHub Actions workflow to commit formatted code with Prettier #6

Update GitHub Actions workflow to commit formatted code with Prettier

Update GitHub Actions workflow to commit formatted code with Prettier #6

Workflow file for this run

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