From 8afdd34732c66c83d22a50c8787d12cf3855c33c Mon Sep 17 00:00:00 2001 From: Raj Date: Wed, 7 Aug 2024 11:37:55 +0530 Subject: [PATCH] refactor: Update Azure deployment workflow to pass staticSites_name as a parameter --- .github/workflows/azuredeploy.arm.yml | 13 ++++++++----- .github/workflows/azuredeploy.bicep.yml | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/azuredeploy.arm.yml b/.github/workflows/azuredeploy.arm.yml index 5eee103..b40bcb5 100644 --- a/.github/workflows/azuredeploy.arm.yml +++ b/.github/workflows/azuredeploy.arm.yml @@ -1,5 +1,8 @@ name: Azure Resource Manager Provision and Deploy on: workflow_dispatch +env: + RESOURCE_GROUP_NAME: helloworld-services + STATIC_WEB_APP_NAME: azure-static-web-apps-001 jobs: @@ -27,17 +30,17 @@ jobs: uses: azure/arm-deploy@v2 with: subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - resourceGroupName: ${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }} + resourceGroupName: ${{ env.RESOURCE_GROUP_NAME }} template: ./infra/azuredeploy.json deploymentMode: Incremental - parameters: staticSites_name=${{ vars.STATIC_WEB_APP_NAME }} + parameters: staticSites_name=${{ env.STATIC_WEB_APP_NAME }} # Get Azure Static Web App deployment token - name: Get Azure Static Web App deployment token id: get-token run: | - TOKEN=$(az staticwebapp secrets list --name ${{ vars.STATIC_WEB_APP_NAME }} --resource-group ${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }} --query "properties.apiKey" -o tsv) - echo "token=$TOKEN" >> $GITHUB_ENV + TOKEN=$(az staticwebapp secrets list --name ${{ env.STATIC_WEB_APP_NAME }} --resource-group ${{ env.RESOURCE_GROUP_NAME }} --query "properties.apiKey" -o tsv) + echo "STATIC_WEB_APP_TOKEN=$TOKEN" >> $GITHUB_ENV # Logout of Azure - name: Logout of Azure @@ -49,7 +52,7 @@ jobs: id: builddeploy uses: Azure/static-web-apps-deploy@v1 with: - azure_static_web_apps_api_token: ${{ env.token }} + azure_static_web_apps_api_token: ${{ env.STATIC_WEB_APP_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }} action: 'upload' app_location: '/src/AspNet.Core.Blazor.WebAssembly' diff --git a/.github/workflows/azuredeploy.bicep.yml b/.github/workflows/azuredeploy.bicep.yml index 0b83b63..21ef214 100644 --- a/.github/workflows/azuredeploy.bicep.yml +++ b/.github/workflows/azuredeploy.bicep.yml @@ -1,5 +1,8 @@ name: Azure Bicep Provision and Deploy on: workflow_dispatch +env: + RESOURCE_GROUP_NAME: helloworld-services + STATIC_WEB_APP_NAME: azure-static-web-apps-001 jobs: @@ -27,17 +30,17 @@ jobs: uses: azure/arm-deploy@v2 with: subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - resourceGroupName: ${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }} + resourceGroupName: ${{ env.RESOURCE_GROUP_NAME }} template: ./infra/azuredeploy.bicep deploymentMode: Incremental - parameters: staticSites_name=${{ vars.STATIC_WEB_APP_NAME }} + parameters: staticSites_name=${{ env.STATIC_WEB_APP_NAME }} # Get Azure Static Web App deployment token - name: Get Azure Static Web App deployment token id: get-token run: | - TOKEN=$(az staticwebapp secrets list --name ${{ vars.STATIC_WEB_APP_NAME }} --resource-group ${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }} --query "properties.apiKey" -o tsv) - echo "token=$TOKEN" >> $GITHUB_ENV + TOKEN=$(az staticwebapp secrets list --name ${{ env.STATIC_WEB_APP_NAME }} --resource-group ${{ env.RESOURCE_GROUP_NAME }} --query "properties.apiKey" -o tsv) + echo "STATIC_WEB_APP_TOKEN=$TOKEN" >> $GITHUB_ENV # Logout of Azure - name: Logout of Azure @@ -49,7 +52,7 @@ jobs: id: builddeploy uses: Azure/static-web-apps-deploy@v1 with: - azure_static_web_apps_api_token: ${{ env.token }} + azure_static_web_apps_api_token: ${{ env.STATIC_WEB_APP_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }} action: 'upload' app_location: '/src/AspNet.Core.Blazor.WebAssembly'