Skip to content

Add workflow for automatically formatting on PR #5

Add workflow for automatically formatting on PR

Add workflow for automatically formatting on PR #5

Workflow file for this run

name: Format code
on:
pull_request:
branches:
- main
jobs:
format:
name: Format code
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
# Check out the branch that the PR refers to, so the git HEAD isn't detached.
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- run: npx prettier --write .
- name: Push changes
run: |
if [ -n "$(git status --porcelain)" ]; then
# github-actions name and email derived from https://github.com/orgs/community/discussions/26560
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git commit -am "Automatic formatting"
git push
fi