Skip to content
This repository was archived by the owner on Feb 19, 2024. It is now read-only.

Commit 33b8157

Browse files
authored
ci(style): ensure PRs follow code style (#258)
1 parent 65db383 commit 33b8157

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

.eslintrc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"extends": [
3-
"./index.js"
4-
]
5-
}
2+
"extends": ["./index.js"]
3+
}

.github/workflows/code-style.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Ensure source code is properly formatted
2+
3+
on: pull_request
4+
5+
permissions:
6+
contents: write
7+
pull-requests: write
8+
9+
jobs:
10+
style:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
ref: ${{ github.event.pull_request.head.ref }}
18+
repository: ${{ github.event.pull_request.head.repo.full_name }}
19+
20+
- uses: actions/setup-node@v3
21+
with:
22+
node-version: "16.x"
23+
24+
- name: Keep npm cache around to speed up installs
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.npm
28+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Format source code with prettier
34+
run: npx prettier --write ./
35+
36+
- name: Check source code with eslint
37+
run: npx eslint --fix --ext .js,.ts,.jsx,.tsx --ignore-pattern commitlint.config.js --ignore-path .gitignore ./
38+
39+
- name: Commit changes
40+
run: |
41+
if ! git diff --exit-code --name-only; then
42+
echo "machine github.com login accesskey password ${{ secrets.GITHUB_TOKEN }}" > ~/.netrc
43+
git config --global user.email "[email protected]"
44+
git config --global user.name "GitHub Actions"
45+
git add -A
46+
git commit -m "style: ensure source code is properly formatted"
47+
git push origin HEAD:${{ github.event.pull_request.head.ref }}
48+
fi

0 commit comments

Comments
 (0)