-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (79 loc) · 2.82 KB
/
annotate-code-style.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Annotate code style
on:
pull_request:
workflow_dispatch:
inputs:
autoFix:
description: "Auto Fix"
required: false
default: "true"
type: boolean
blackAutoFix:
description: "Black Auto Fix"
required: false
default: "true"
type: boolean
prettierAutoFix:
description: "Prettier Auto Fix"
required: false
default: "true"
type: boolean
clientLintAutoFix:
description: "Client (TSLint) Auto Fix"
required: false
default: "false"
type: boolean
# This feature would be nice to have yet it is not supported yet by `lint-action`.
# See
# - https://github.com/wearerequired/lint-action/issues/559
#
# Meanwhile we can use workflow_dispatch to trigger the action manually.
#
# issue_comment:
# types: [created]
# Down scope as necessary via https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
checks: write
contents: write
pull-requests: write
env:
AUTOFIX_URL: ${{ github.server_url }}/${{ github.repository }}/actions/manual?branch=${{ github.head_ref || github.ref_name }}&workflow=.github%2Fworkflows%2Fannotate-code-style.yml
jobs:
run-linters:
name: Annotate code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.ACTION_TOKEN }}
- name: Annotate code style
uses: wearerequired/lint-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
auto_fix: ${{ github.event.inputs.autoFix }}
neutral_check_on_warning: true
continue_on_error: false
black: true
black_auto_fix: ${{ github.event.inputs.blackAutoFix || true }}
black_command_prefix: |
docker run --rm -v $(pwd):/work --workdir /work pyfound/black:23.3.0
black_args: --skip-string-normalization
prettier: true
prettier_auto_fix: ${{ github.event.inputs.prettierAutoFix || true }}
prettier_command_prefix: |
docker run --rm -v $(pwd):/work tmknom/prettier:2.8.7
prettier_args: --ignore-unknown
- name: Inform how to run autofix
if: failure() && (github.event_name == 'pull_request')
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Code style issues has been found - [AUTOFIX](${{ env.AUTOFIX_URL }})"
})
- name: Client linting autofix
if: github.event.inputs.autoFix && github.event.inputs.tslintAutoFix
uses: ./.github/actions/client-lint-autofix