Skip to content

ci: update linting workflow to handle YAML, Bash, Markdown, and Terraform #1354

ci: update linting workflow to handle YAML, Bash, Markdown, and Terraform

ci: update linting workflow to handle YAML, Bash, Markdown, and Terraform #1354

Workflow file for this run

---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Lint Job
on:
pull_request: {}
workflow_dispatch:
inputs:
run-all:
description: "Whether to run all linters or only the ones that have changes"
required: false
default: false
type: boolean
jobs:
paths-filter:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
outputs:
filter: ${{ steps.filter.outputs.workflows }}
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Scan Paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
yaml:
- '**/*.yml'
- '**/*.yaml'
bash:
- '**/*.sh'
markdown:
- '**/*.md'
terraform:
- '**/*.tf'
yamllint:
runs-on: ubuntu-latest
needs: [paths-filter]
if: needs.check-changes.outputs.yaml == 'true' || github.event.inputs.run-all == true
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.12"
- name: Install yamllint
run: pip install yamllint
- name: Run yamllint
run: yamllint -c .github/configs/yamllint.yaml .
shellcheck:
runs-on: ubuntu-latest
needs: [paths-filter]
if: needs.check-changes.outputs.bash == 'true' || github.event.inputs.run-all == true
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install ShellCheck
run: sudo apt-get install -y shellcheck
- name: Run ShellCheck
run: find . -name "*.sh" -exec shellcheck {} +
markdownlint:
runs-on: ubuntu-latest
needs: [paths-filter]
if: needs.check-changes.outputs.markdown == 'true' || github.event.inputs.run-all == true
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install Node.js
uses: actions/[email protected]
with:
node-version: "20"
- name: Install markdownlint-cli
run: npm install -g markdownlint-cli
- name: Run markdownlint
run: markdownlint '**/*.md'
tflint:
runs-on: ubuntu-latest
needs: [paths-filter]
if: needs.check-changes.outputs.terraform == 'true' || github.event.inputs.run-all == true
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: terraform-linters/setup-tflint@v4
name: Setup TFLint
with:
tflint_version: v0.53.0
- name: Show TFLint version
run: tflint --version
- name: Init TFLint
run: tflint --init
- name: Run TFLint
run: tflint --format=compact --recursive