Skip to content

fix: Various fixes and example implementation #2

fix: Various fixes and example implementation

fix: Various fixes and example implementation #2

name: pre-commit & tests
on:
workflow_dispatch:
pull_request:
branches:
- main
- master
- develop
permissions:
id-token: write
contents: read
defaults:
# Set shell for steps inside containers (default=sh)
run:
shell: bash
jobs:
#--------------------------------------------------------------
# PRE-COMMIT
#--------------------------------------------------------------
pre_commit:
name: 💍 pre-commit
# For public repos use runs-on: ubuntu-latest
# For private repos use runs-on: self-hosted
runs-on: ubuntu-latest
container: bjorncloudandthings/terraform-aws-github:latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- uses: hashicorp/setup-terraform@v2
- name: Install requirements
run: |
python -m venv .venv
source .venv/bin/activate
pip install pre-commit
- name: pre-commit run
run: |
source .venv/bin/activate
if [[ "${{ env.GITHUB_REPOSITORY}}" == "cloudandthings/terraform-aws-template" ]]; then
export SKIP=no-vanilla-readme
fi
echo ...running developer pre-commit checks...
pre-commit run --config .pre-commit-config.yaml --all-files --show-diff-on-failure
if [[ -f .github/.pre-commit-config.yaml ]]; then
echo ...running remote pre-commit checks...
pip install checkov
pre-commit run --config .github/.pre-commit-config.yaml --all-files --show-diff-on-failure
fi
- name: cat pre-commit log
if: failure()
run: |
LOG_FILE=~/.cache/pre-commit/pre-commit.log
[ -f $LOG_FILE ] && cat $LOG_FILE