This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
60 lines (60 loc) · 2.77 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
59
60
name: 'ESLint Analysis Action'
description: 'Runs ESLint based on the ruleset defined - https://eslint.org/'
branding:
icon: 'zoom-in'
color: 'yellow'
inputs:
analyse-all-code:
description: 'Used to determine whether you just want to analyse the files changed or the whole repository.'
required: false
default: 'false'
auth-token:
description: 'If you are looking to compare the file difference based on the GitHub pull request, you will need to specify the [GitHub secrets token](https://docs.github.com/en/actions/reference/authentication-in-a-workflow)'
required: false
eslint-version:
description: 'The version of ESLint you would like to run. Applicable when you are not installing via package.json.'
required: false
default: '7.23.0'
file-diff-type:
description: 'Choose whether you want the file comparison to be based on a git diff or based on the files changed specified on the GitHub pull request. Note that if you use the GitHub pull request option, this action will only work on a pull request event. Options to set this are either `git` or `github`.'
required: false
default: 'git'
file-path:
description: 'Path to the sources to analyse. This can be a file name or a directory. Should be used when analysing the whole code base.'
required: false
default: '**/**'
rules-path:
description: 'The ESLint ruleset file you want to use for the analysis.'
required: false
default: './eslintrc.json'
setup-from-package-json:
description: 'You can manage your ESLint setup via package.json configuration in your project. Recommended if you are working with plugins.'
required: false
default: 'false'
runs:
using: "composite"
steps:
- id: branches
run: |
if [ ${{ github.event_name }} == 'pull_request' ]; then
echo "::set-output name=target::${{ github.base_ref }}"
echo "::set-output name=source::${{ github.head_ref }}"
else
echo "::set-output name=target::${{ github.event.repository.default_branch }}"
echo "::set-output name=source::${{ github.ref }}"
fi
shell: bash
- run: ${{ github.action_path }}/eslint.sh
shell: bash
env:
ESLINT_VERSION: ${{ inputs.eslint-version }}
SETUP_FROM_PACKAGE_JSON: ${{ inputs.setup-from-package-json }}
FILE_PATH: ${{ inputs.file-path }}
RULES_PATH: ${{ inputs.rules-path }}
ANALYSE_ALL_CODE: ${{ inputs.analyse-all-code }}
TARGET_BRANCH: ${{ steps.branches.outputs.target }}
SOURCE_BRANCH: ${{ steps.branches.outputs.source }}
REPO_NAME: ${{ github.event.repository.full_name }}
PR_NUMBER: ${{ github.event.number }}
AUTH_TOKEN: ${{ inputs.auth-token }}
FILE_DIFF_TYPE: ${{ inputs.file-diff-type }}