Skip to content

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.

License

Notifications You must be signed in to change notification settings

Azure4DevOps/check-azure-bicep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status CI GitHub release (latest SemVer) GitHub release (latest by date including pre-releases) pre-commit

check-azure-bicep

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.

About

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.

Demo

Example usage of pre-commit run --all-files and git commit after hook innstall in git repository pre-commit install

alt text

Azure Bicep Install

To install az bicep use install or install or az bicep install for Azure cli.

pre-commit Install

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

Example usage

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

Example local run

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

Example Azure Pipelines usage azure-pipelines-ci.yml

pool:
  vmImage: "ubuntu-latest"
steps:
  - script: |
      pip install pre-commit
      pre-commit --version
      pre-commit run --all-files
    displayName: Execute pre-commit

Example Github Workflow usage github-action-ci.yml

build:
  runs-on: ubuntu-latest
  steps:
    - name: Execute pre-commit
      run: |
        pip install pre-commit
        pre-commit --version
        pre-commit run --all-files

📄 License

This project is distributed under the terms of the MIT license.

About

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.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •