diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 09d374f..dec9fa4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,10 @@ name: lint -on: [push, pull_request] +on: + pull_request: + push: + branches: + - main jobs: build: @@ -8,18 +12,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Run pre-commit test + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - name: Install pre-commit dependency - terraform-docs run: | - sudo apt-get install python3-pip gawk - curl https://pre-commit.com/install-local.py | python3 - - # Terraform Docs - curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/v0.9.1/terraform-docs-v0.9.1-$(uname | tr '[:upper:]' '[:lower:]')-amd64 - chmod +x ./terraform-docs - sudo mv ./terraform-docs /usr/bin/terraform-docs - # Tflint - curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/ - # Run pre-commit - /home/runner/bin/pre-commit --version - terraform-docs --version - /home/runner/bin/pre-commit run -a + TF_DOCS_VER="v0.9.1" + pushd /tmp + curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/${TF_DOCS_VER}/terraform-docs-${TF_DOCS_VER}-$(uname | tr '[:upper:]' '[:lower:]')-amd64 && chmod +x ./terraform-docs && sudo mv ./terraform-docs /usr/bin/ + popd + - name: Install pre-commit dependency - tflint + uses: terraform-linters/setup-tflint@v2 + with: + tflint_version: v0.34.0 + - name: Run pre-commit test + uses: pre-commit/action@v3.0.0 + with: + extra_args: --all-files \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aaf23da..0c5dfbe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ repos: -- repo: git://github.com/antonbabenko/pre-commit-terraform +- repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.43.0 hooks: - id: terraform_fmt