Skip to content

Commit 75cfa1b

Browse files
authored
Update update-styles-json.yml - merged the formatting action
1 parent 8354fa4 commit 75cfa1b

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

.github/workflows/update-styles-json.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
name: Update styles.json
1+
name: Format and Update styles.json
22

33
on:
44
push:
55
paths:
66
- "websites/**/*.css"
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
712
workflow_dispatch:
813

914
jobs:
10-
update-styles-json:
15+
format-and-update:
16+
name: Format and Update JSON
1117
runs-on: ubuntu-latest
1218

1319
steps:
14-
- name: Checkout repository content
15-
uses: actions/checkout@v2
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
ref: ${{ github.head_ref }}
1625

1726
- name: Set up Node.js
1827
uses: actions/setup-node@v2
@@ -22,22 +31,27 @@ jobs:
2231
- name: Install dependencies
2332
run: npm install
2433

34+
- name: Run Prettier
35+
uses: creyD/[email protected]
36+
with:
37+
prettier_options: '--write .'
38+
commit_message: "gh-actions: format code"
39+
github_token: ${{ secrets.GITHUB_TOKEN }}
40+
2541
- name: Run script to update styles.json
2642
run: node update-styles-json.cjs
2743

2844
- name: Validate styles.json
29-
run: |
30-
jq empty styles.json
45+
run: jq empty styles.json
3146

32-
- name: Commit and push changes
47+
- name: Commit and push styles.json if changed
3348
run: |
3449
git config --global user.name 'github-actions[bot]'
3550
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
3651
git add styles.json
3752
38-
# Try to commit. If nothing to commit, exit successfully.
3953
if git diff --cached --quiet; then
40-
echo "No changes to commit."
54+
echo "No changes to styles.json."
4155
exit 0
4256
fi
4357

0 commit comments

Comments
 (0)