feat: Add support for aws_backup_logically_air_gapped_vault #49
Workflow file for this run
This file contains hidden or 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: Pre-commit | |
on: | |
pull_request: | |
branches: [master] | |
paths: | |
- '**.tf' | |
- '**.tfvars' | |
- '**.md' | |
- '.pre-commit-config.yaml' | |
push: | |
branches: [master] | |
paths: | |
- '**.tf' | |
- '**.tfvars' | |
- '**.md' | |
- '.pre-commit-config.yaml' | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
permissions: | |
contents: read | |
pull-requests: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v5 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Set up Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: '1.3.0' | |
- name: Cache terraform tools | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.local/bin/terraform-docs | |
~/.local/bin/tflint | |
key: terraform-tools-${{ runner.os }}-v1 | |
restore-keys: | | |
terraform-tools-${{ runner.os }}- | |
- name: Install terraform-docs | |
run: | | |
if [ ! -f ~/.local/bin/terraform-docs ]; then | |
echo "Installing terraform-docs..." | |
mkdir -p ~/.local/bin | |
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.16.0/terraform-docs-v0.16.0-$(uname)-amd64.tar.gz | |
tar -xzf terraform-docs.tar.gz | |
chmod +x terraform-docs | |
mv terraform-docs ~/.local/bin/ | |
rm terraform-docs.tar.gz | |
fi | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Install tflint | |
run: | | |
if ! command -v tflint &> /dev/null; then | |
echo "Installing tflint..." | |
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash | |
fi | |
- name: Install pre-commit | |
run: | | |
python -m pip install --upgrade pip | |
pip install pre-commit | |
- name: Cache pre-commit hooks | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
restore-keys: | | |
pre-commit-${{ runner.os }}- | |
- name: Install pre-commit hooks | |
run: pre-commit install-hooks | |
- name: Run pre-commit on all files (push to master) | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
run: pre-commit run --all-files | |
- name: Run pre-commit on changed files (pull request) | |
if: github.event_name == 'pull_request' | |
run: | | |
# Get the list of changed files | |
git fetch origin ${{ github.base_ref }} | |
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.tf' '*.tfvars' '*.md') | |
if [ -n "$CHANGED_FILES" ]; then | |
echo "Running pre-commit on changed files:" | |
echo "$CHANGED_FILES" | |
pre-commit run --files $CHANGED_FILES | |
else | |
echo "No relevant files changed, skipping pre-commit checks" | |
fi | |
- name: Pre-commit summary | |
if: always() | |
run: | | |
echo "## 🔍 Pre-commit Results" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
if [ "${{ job.status }}" == "success" ]; then | |
echo "✅ All pre-commit checks passed!" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "**Tools verified:**" >> $GITHUB_STEP_SUMMARY | |
echo "- 🔧 Terraform formatting" >> $GITHUB_STEP_SUMMARY | |
echo "- ✅ Terraform validation" >> $GITHUB_STEP_SUMMARY | |
echo "- 📚 Documentation generation" >> $GITHUB_STEP_SUMMARY | |
echo "- 🔍 TFLint analysis" >> $GITHUB_STEP_SUMMARY | |
echo "- 🧹 File formatting" >> $GITHUB_STEP_SUMMARY | |
else | |
echo "❌ Pre-commit checks failed" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "Please check the logs above for specific failures." >> $GITHUB_STEP_SUMMARY | |
echo "You can run \`pre-commit run --all-files\` locally to fix issues." >> $GITHUB_STEP_SUMMARY | |
fi | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "**Configured hooks:**" >> $GITHUB_STEP_SUMMARY | |
echo "- trailing-whitespace" >> $GITHUB_STEP_SUMMARY | |
echo "- end-of-file-fixer" >> $GITHUB_STEP_SUMMARY | |
echo "- check-yaml" >> $GITHUB_STEP_SUMMARY | |
echo "- terraform_fmt" >> $GITHUB_STEP_SUMMARY | |
echo "- terraform_validate" >> $GITHUB_STEP_SUMMARY | |
echo "- terraform_docs" >> $GITHUB_STEP_SUMMARY | |
echo "- terraform_tflint" >> $GITHUB_STEP_SUMMARY |