1
- name : Update styles.json
1
+ name : Format and Update styles.json
2
2
3
3
on :
4
4
push :
5
5
paths :
6
6
- " websites/**/*.css"
7
+ branches :
8
+ - main
9
+ pull_request :
10
+ branches :
11
+ - main
7
12
workflow_dispatch :
8
13
9
14
jobs :
10
- update-styles-json :
15
+ format-and-update :
16
+ name : Format and Update JSON
11
17
runs-on : ubuntu-latest
12
18
13
19
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 }}
16
25
17
26
- name : Set up Node.js
18
27
uses : actions/setup-node@v2
@@ -22,22 +31,27 @@ jobs:
22
31
- name : Install dependencies
23
32
run : npm install
24
33
34
+ - name : Run Prettier
35
+
36
+ with :
37
+ prettier_options : ' --write .'
38
+ commit_message : " gh-actions: format code"
39
+ github_token : ${{ secrets.GITHUB_TOKEN }}
40
+
25
41
- name : Run script to update styles.json
26
42
run : node update-styles-json.cjs
27
43
28
44
- name : Validate styles.json
29
- run : |
30
- jq empty styles.json
45
+ run : jq empty styles.json
31
46
32
- - name : Commit and push changes
47
+ - name : Commit and push styles.json if changed
33
48
run : |
34
49
git config --global user.name 'github-actions[bot]'
35
50
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
36
51
git add styles.json
37
52
38
- # Try to commit. If nothing to commit, exit successfully.
39
53
if git diff --cached --quiet; then
40
- echo "No changes to commit ."
54
+ echo "No changes to styles.json ."
41
55
exit 0
42
56
fi
43
57
0 commit comments