Annotate code style #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
# Set ACTION_TOKEN to re-run this action after autofix | |
token: ${{ secrets.ACTION_TOKEN || secrets.GITHUB_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') | |
run: | | |
echo "Code style issues has been found - [AUTOFIX]($AUTOFIX_URL)" | tee $GITHUB_STEP_SUMMARY | |
- name: Client linting autofix | |
if: github.event.inputs.autoFix && github.event.inputs.tslintAutoFix | |
uses: ./.github/actions/client-lint-autofix |