pre-commit hooks for Azure Bicep validation, with built-in support for GitHub Workflows, Azure Pipelines, and more! Enabling shift left approach for Azure Bicep infrastructure as code.
This repository provide one hook to use with pre-commit that validate bicep files: it will call az bicep build
.
It requires the az bicep
toolchain installed, and uses az bicep
under the hood.
Example usage of pre-commit run --all-files
and
git commit
after hook innstall in git repository pre-commit install
To install az bicep
use install or install or az bicep install
for Azure cli.
Before you can run hooks, you need to have the pre-commit package manager installed. Using pip:
# install using pip
pip install pre-commit
# check if working - expected print with version like `pre-commit 3.2.2`
pre-commit --version
# setup the git repo for hooks
pre-commit install
# periodically run updates to your pre-commit config to make sure you always have the latest version of the hooks
pre-commit autoupdate
Add a snippet to your .pre-commit-config.yaml
file in root of repository.
- repo: https://github.com/Azure4DevOps/check-azure-bicep
rev: v0.2.1 # ${LATEST_SHA_OR_VERSION}
hooks:
- id: check-azure-bicep
run pre-commit install
to set up the git hook scripts in your git repository # scan all modyfied miles before making commint (git hooks)
or
run pre-commit run --all-files
# scanning all files
at result all bicep files will or modified will be validated doing az bicep build
pool:
vmImage: "ubuntu-latest"
steps:
- script: |
pip install pre-commit
pre-commit --version
pre-commit run --all-files
displayName: Execute pre-commit
build:
runs-on: ubuntu-latest
steps:
- name: Execute pre-commit
run: |
pip install pre-commit
pre-commit --version
pre-commit run --all-files
This project is distributed under the terms of the MIT license.