-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
58 lines (53 loc) · 1.72 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: 'Prettier Check'
author: 'Rutaj Dash'
description: 'A simple action which runs the Prettier CLI Check'
inputs:
file_pattern:
description: 'The file pattern to scan'
required: false
default: '**/*.js'
config_path:
description: 'The path to the prettierrc file'
required: false
default: ''
ignore_path:
description: 'The path to the prettierignore file'
required: false
default: './.prettierignore'
prettier_version:
description: 'The version of prettier to install'
required: false
default: 'latest'
fail_on_error:
description: 'Whether the script should fail when linting errors are found'
required: false
default: true
outputs:
prettier_output:
description: 'The output from prettier'
value: ${{ steps.prettier-run.outputs.prettier-output }}
runs:
using: 'composite'
steps:
- name: Installing Prettier
id: prettier-install
shell: bash
run: npm install --global prettier@${{ inputs.prettier_version }}
- name: Running Prettier
id: prettier-run
shell: bash
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "prettier-output<<$EOF" >> $GITHUB_OUTPUT
echo "$(prettier --list-different --config ${{ inputs.config_path }} --ignore-path ${{ inputs.ignore_path }} --no-error-on-unmatched-pattern ${{ inputs.file_pattern }})" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Fail On Error
id: fail-on-error
if: steps.prettier-run.outputs.prettier-output != 0 && steps.prettier-run.outputs.prettier-output != '' && inputs.fail_on_error
shell: bash
run: |
echo "Found errors"
exit 1
branding:
icon: 'search'
color: 'gray-dark'