Skip to content

Commit

Permalink
refactor: Update Azure deployment workflow to pass staticSites_name a…
Browse files Browse the repository at this point in the history
…s a parameter
  • Loading branch information
Raj committed Aug 7, 2024
1 parent 75bcbd6 commit 8afdd34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/azuredeploy.arm.yml
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/azuredeploy.bicep.yml
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit 8afdd34

Please sign in to comment.