7
7
[ ![ Contributors] ( https://img.shields.io/github/contributors-anon/creyD/prettier_action )] ( https://github.com/creyD/prettier_action/graphs/contributors )
8
8
[ ![ Issues] ( https://img.shields.io/github/issues/creyD/prettier_action )] ( https://github.com/creyD/prettier_action/issues )
9
9
10
-
11
10
A GitHub action for styling files with [ prettier] ( https://prettier.io ) .
12
11
13
12
## Usage
@@ -35,7 +34,9 @@ A GitHub action for styling files with [prettier](https://prettier.io).
35
34
### Example Config
36
35
37
36
> Hint: if you still use the old naming convention or generally a different branch name, please replace the ` main ` in the following configurations.
37
+
38
38
#### Example 1 (run on push in branch main)
39
+
39
40
``` yaml
40
41
name : Continuous Integration
41
42
44
45
pull_request :
45
46
push :
46
47
branches :
47
- - main
48
+ - main
48
49
49
50
jobs :
50
51
prettier :
51
52
runs-on : ubuntu-latest
52
53
53
54
steps :
54
- - name : Checkout
55
- uses : actions/checkout@v2
56
- with :
57
- # Make sure the actual branch is checked out when running on pull requests
58
- ref : ${{ github.head_ref }}
59
-
60
- - name : Prettify code
61
- uses : creyD/prettier_action@v4.1.1
62
- with :
63
- # This part is also where you can pass other options, for example:
64
- prettier_options : --write **/*.{js,md}
55
+ - name : Checkout
56
+ uses : actions/checkout@v2
57
+ with :
58
+ # Make sure the actual branch is checked out when running on pull requests
59
+ ref : ${{ github.head_ref }}
60
+
61
+ - name : Prettify code
62
+ uses : creyD/prettier_action@v4.2
63
+ with :
64
+ # This part is also where you can pass other options, for example:
65
+ prettier_options : --write **/*.{js,md}
65
66
` ` `
66
67
67
68
#### Example 2 (using the only_changed or same_commit option on PR)
69
+
68
70
` ` ` yaml
69
71
name : Continuous Integration
70
72
@@ -77,23 +79,24 @@ jobs:
77
79
runs-on : ubuntu-latest
78
80
79
81
steps :
80
- - name : Checkout
81
- uses : actions/checkout@v2
82
- with :
83
- # Make sure the actual branch is checked out when running on pull requests
84
- ref : ${{ github.head_ref }}
85
- # This is important to fetch the changes to the previous commit
86
- fetch-depth : 0
87
-
88
- - name : Prettify code
89
- uses : creyD/prettier_action@v4.1.1
90
- with :
91
- # This part is also where you can pass other options, for example:
92
- prettier_options : --write **/*.{js,md}
93
- only_changed : True
82
+ - name : Checkout
83
+ uses : actions/checkout@v2
84
+ with :
85
+ # Make sure the actual branch is checked out when running on pull requests
86
+ ref : ${{ github.head_ref }}
87
+ # This is important to fetch the changes to the previous commit
88
+ fetch-depth : 0
89
+
90
+ - name : Prettify code
91
+ uses : creyD/prettier_action@v4.2
92
+ with :
93
+ # This part is also where you can pass other options, for example:
94
+ prettier_options : --write **/*.{js,md}
95
+ only_changed : True
94
96
` ` `
95
97
96
98
#### Example 3 (using a custom access token on PR)
99
+
97
100
` ` ` yaml
98
101
name : Continuous Integration
99
102
@@ -106,24 +109,25 @@ jobs:
106
109
runs-on : ubuntu-latest
107
110
108
111
steps :
109
- - name : Checkout
110
- uses : actions/checkout@v2
111
- with :
112
- fetch-depth : 0
113
- ref : ${{ github.head_ref }}
114
- # Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
115
- persist-credentials : false
116
-
117
- - name : Prettify code
118
- uses : creyD/prettier_action@v4.1
119
- with :
120
- prettier_options : --write **/*.{js,md}
121
- only_changed : True
122
- # Set your custom token
123
- github_token : ${{ secrets.PERSONAL_GITHUB_TOKEN }}
112
+ - name : Checkout
113
+ uses : actions/checkout@v2
114
+ with :
115
+ fetch-depth : 0
116
+ ref : ${{ github.head_ref }}
117
+ # Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
118
+ persist-credentials : false
119
+
120
+ - name : Prettify code
121
+ uses : creyD/prettier_action@v4.2
122
+ with :
123
+ prettier_options : --write **/*.{js,md}
124
+ only_changed : True
125
+ # Set your custom token
126
+ github_token : ${{ secrets.PERSONAL_GITHUB_TOKEN }}
124
127
` ` `
125
128
126
129
#### Example 4 (dry run)
130
+
127
131
` ` ` yaml
128
132
name : Continuous Integration
129
133
@@ -136,19 +140,19 @@ jobs:
136
140
runs-on : ubuntu-latest
137
141
138
142
steps :
139
- - name : Checkout
140
- uses : actions/checkout@v2
141
- with :
142
- fetch-depth : 0
143
- ref : ${{ github.head_ref }}
144
- # Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
145
- persist-credentials : false
146
-
147
- - name : Prettify code
148
- uses : creyD/prettier_action@v4.1
149
- with :
150
- dry : True
151
- github_token : ${{ secrets.PERSONAL_GITHUB_TOKEN }}
143
+ - name : Checkout
144
+ uses : actions/checkout@v2
145
+ with :
146
+ fetch-depth : 0
147
+ ref : ${{ github.head_ref }}
148
+ # Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
149
+ persist-credentials : false
150
+
151
+ - name : Prettify code
152
+ uses : creyD/prettier_action@v4.2
153
+ with :
154
+ dry : True
155
+ github_token : ${{ secrets.PERSONAL_GITHUB_TOKEN }}
152
156
` ` `
153
157
154
158
More documentation for writing a workflow can be found [here](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions).
0 commit comments