-
Notifications
You must be signed in to change notification settings - Fork 21
44 lines (41 loc) · 1.57 KB
/
formatting.yml
File metadata and controls
44 lines (41 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Formatting
on:
pull_request:
merge_group:
jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Checkout
# Check this is not a PR from a fork
if: github.event.pull_request.head.repo.full_name == github.repository
uses: actions/checkout@v6
with:
# Use the head ref so we can commit to the branch
ref: ${{ github.head_ref || github.ref }}
# We need to use a personal access token (PAT) with repo scope
# as the default GITHUB_TOKEN won’t trigger new workflow runs if
# a commit is made (to avoid accidental infinite recursion).
token: ${{ secrets.AUTOLINT_TOKEN }}
- name: Checkout
# Checkout the default way if it is a fork
if: github.event.pull_request.head.repo.full_name != github.repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci --include=dev
- name: Run formatter
run: npm run lint:prettier:fix
- name: Commit any formatting changes
# Skip this step if it’s a fork, as we won’t have permission to commit
if: github.event.pull_request.head.repo.full_name == github.repository
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add --all
git commit -m "Apply formatting" || exit 0
git push