Skip to content

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

Notifications You must be signed in to change notification settings

cwiederspan/az-gitops-ghaction-bicep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 [email protected] for more information on this repository.

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published