Azure Bicep Provision and Deploy #8
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
name: Azure Bicep Provision and Deploy | |
on: workflow_dispatch | |
jobs: | |
#====== Provision ======# | |
provision: | |
name: "Provision" | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Login to Azure | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
# Deploy Bicep template | |
- name: Deploy Bicep Template | |
uses: azure/arm-deploy@v2 | |
id: deploy | |
with: | |
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
resourceGroupName: ${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }} | |
template: ./infra/azuredeploy.bicep | |
deploymentMode: Incremental | |
deploymentName: staticWebAppDeployment | |
# Get Azure Static Web App deployment token | |
- name: Get Azure Static Web App deployment token | |
id: get-token | |
run: | | |
STATIC_WEB_APP_NAME=$(az deployment group show --resource-group ${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }} --name staticWebAppDeployment --query "properties.outputs.staticWebAppName.value" -o tsv) | |
TOKEN=$(az staticwebapp secrets list --name $STATIC_WEB_APP_NAME --resource-group ${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }} --query "properties.apiKey" -o tsv) | |
echo "token=$TOKEN" >> $GITHUB_ENV | |
echo "staticWebAppName=$STATIC_WEB_APP_NAME" >> $GITHUB_ENV | |
# Debug step to print the token value | |
- name: Debug - Print token value | |
run: | | |
echo "Token: ${{ env.token }}" | |
# Logout of Azure | |
- name: Logout of Azure | |
run: | | |
az logout | |
outputs: | |
token: ${{ steps.get-token.outputs.token }} | |
staticWebAppName: ${{ steps.get-token.outputs.staticWebAppName }} | |
#====== Build and deploy ======# | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
name: "Build and Deploy" | |
needs: provision | |
steps: | |
# Checkout repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
# Deploy to Azure Static Web Apps | |
- name: Deploy | |
id: builddeploy | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ needs.provision.outputs.token }} | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
action: 'upload' | |
app_location: '/src/AspNet.Core.Blazor.WebAssembly' | |
output_location: 'wwwroot' | |