You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64-8
Original file line number
Diff line number
Diff line change
@@ -16,15 +16,17 @@ A GitHub action for styling files with [prettier](https://prettier.io).
16
16
17
17
| Parameter | Required | Default | Description |
18
18
| - | :-: | :-: | - |
19
-
| dry |:x:|`false`| Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. |
19
+
| dry |:x:|`false`| Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. Recommended to use with prettier_options --check |
20
20
| prettier_version |:x:|`false`| Specific prettier version (by default use latest) |
21
21
| prettier_options |:x:|`"--write **/*.js"`| Prettier options (by default it applies to the whole repository) |
| same_commit |:x:|`false`| Update the current commit instead of creating a new one, created by [Joren Broekema](https://github.com/jorenbroekema), this command works only with the checkout action set to fetch depth '0' (see example 2) |
24
25
| commit_message |:x:|`"Prettified Code!"`| Custom git commit message, will be ignored if used with `same_commit`|
25
26
| file_pattern |:x:|`*`| Custom git add file pattern, can't be used with only_changed! |
26
-
| prettier_plugins |:x:|``| Install Prettier plugins, i.e. `@prettier/prettier-php @prettier/some-other-plugin`|
27
+
| prettier_plugins |:x:|- | Install Prettier plugins, i.e. `@prettier/plugin-php @prettier/plugin-other`|
27
28
| only_changed |:x:|`false`| Only prettify changed files, can't be used with file_pattern! This command works only with the checkout action set to fetch depth '0' (see example 2)|
29
+
| github_token | :x: | `${{ github.token }}` | The default [GITHUB_TOKEN](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret) or a [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)
28
30
29
31
> Note: using the same_commit option may lead to problems if other actions are relying on the commit being the same before and after the prettier action has ran. Keep this in mind.
30
32
@@ -53,12 +55,10 @@ jobs:
53
55
ref: ${{ github.head_ref }}
54
56
55
57
- name: Prettify code
56
-
uses: creyD/prettier_action@v3.3
58
+
uses: creyD/prettier_action@v4.0
57
59
with:
58
60
# This part is also where you can pass other options, for example:
59
61
prettier_options: --write **/*.{js,md}
60
-
env:
61
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62
62
```
63
63
64
64
#### Example 2 (using the only_changed or same_commit option on PR)
@@ -83,13 +83,69 @@ jobs:
83
83
fetch-depth: 0
84
84
85
85
- name: Prettify code
86
-
uses: creyD/prettier_action@v3.3
86
+
uses: creyD/prettier_action@v4.0
87
87
with:
88
88
# This part is also where you can pass other options, for example:
89
89
prettier_options: --write **/*.{js,md}
90
90
only_changed: True
91
-
env:
92
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91
+
```
92
+
93
+
#### Example 3 (using a custom access token on PR)
94
+
```yaml
95
+
name: Continuous Integration
96
+
97
+
on:
98
+
pull_request:
99
+
branches: [master]
100
+
101
+
jobs:
102
+
prettier:
103
+
runs-on: ubuntu-latest
104
+
105
+
steps:
106
+
- name: Checkout
107
+
uses: actions/checkout@v2
108
+
with:
109
+
fetch-depth: 0
110
+
ref: ${{ github.head_ref }}
111
+
# Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
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).
Copy file name to clipboardExpand all lines: entrypoint.sh
+46-9
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,19 @@
1
-
#!/bin/sh
1
+
#!/bin/bash
2
2
# e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set
3
3
# x would be for showing the commands before they are executed
4
4
set -eu
5
+
shopt -s globstar
5
6
6
7
# FUNCTIONS
7
8
# Function for setting up git env in the docker container (copied from https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh)
0 commit comments