cwiederspan / az-gitops-ghaction-bicep

An example of a GitOps-like workflow to deploy Azure resources using Azure Bicep files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitOps using GitHub Actions with Azure

This is an example of creating a GitOps-like approach for automatically executing any Azure Bicep files within the repository using a GitHub Action workflow.

In this case, there is a simple main.bicep file that will create an Azure storage account.

The gitops.yaml GitHub Action file that will use the ARM Deploy action to execute the Bicep file whenever the repo is committed.

Setup


# Create some variables for reuse
AZURE_SUB_ID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
AZURE_RG=cdw-azgitops-20210418
LOCATION=westus2

# Log into Azure
az login

# Create a Resource Group
az group create -n $AZURE_RG -l $LOCATION

# Create an SP for the Resource Group
AZURE_CREDS=$(az ad sp create-for-rbac \
    --name $AZURE_RG-sp \
    --role contributor \
    --scopes /subscriptions/$AZURE_SUB_ID/resourceGroups/$AZURE_RG \
    --sdk-auth)

# Set the values into a GitHub secrets
gh secret set AZURE_CREDENTIALS -b"$AZURE_CREDS"
gh secret set AZURE_RG -b"$AZURE_RG"
gh secret set AZURE_SUBSCRIPTION -b"$AZURE_SUB_ID"

Follow Up

Email chwieder@microsoft.com for more information on this repository.

About

An example of a GitOps-like workflow to deploy Azure resources using Azure Bicep files.


Languages

Language:Shell 91.8%Language:Dockerfile 6.6%Language:Bicep 1.7%