Azure Bicep #6
This file contains 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
# https://learn.microsoft.com/ja-jp/azure/azure-resource-manager/bicep/deploy-github-actions | |
name: Azure Bicep | |
on: | |
workflow_dispatch: | |
inputs: | |
delete-group: | |
description: 'Delete resource group after deployment' | |
required: false | |
default: false | |
type: boolean | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
deploy-bicep: | |
runs-on: ubuntu-latest | |
environment: Production | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Azure CLI | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Create resource group | |
id: resourceGroup | |
run: | | |
RESOURCE_GROUP=rg-bicep-from-actions-$RANDOM | |
echo "group-name=$RESOURCE_GROUP" >> $GITHUB_OUTPUT | |
az group create --name $RESOURCE_GROUP --location japaneast | |
- name: Deploy Bicep | |
uses: azure/arm-deploy@v2 | |
with: | |
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
resourceGroupName: ${{ steps.resourceGroup.outputs.group-name }} | |
template: ./bicep/main.bicep | |
parameters: 'storagePrefix=yuta storageSKU=Standard_LRS' | |
failOnStdErr: false | |
- name: Delete resource group | |
if: ${{ github.event.inputs.delete-group }} | |
run: | | |
az group delete --name ${{ steps.resourceGroup.outputs.group-name }} --yes --no-wait | |
- name: Az CLI Logout | |
run: az logout |