forked from justinyoo/ignite-spotlight-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (80 loc) · 3.5 KB
/
workflow_call_deploy_sttapp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Deploy SWA to Azure
on:
workflow_call:
inputs:
artifact_name:
type: string
required: false
description: Artifact name
default: 'app'
env:
AZURE_RESOURCE_GROUP_NAME: 'rg-${{ secrets.AZURE_ENV_NAME }}'
jobs:
build_and_deploy:
runs-on: ubuntu-latest
env:
AZURE_APIM_NAME: 'apim-${{ secrets.AZURE_ENV_NAME }}'
AZURE_STTAPP_NAME: 'sttapp-${{ secrets.AZURE_ENV_NAME }}'
steps:
- name: Download Function app artifact
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}/published
- name: Login to Azure
uses: Azure/login@v1
with:
# creds: ${{ secrets.AZURE_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# - name: Get APIM endpoint
# shell: bash
# run: |
# subscription_id=$(az account show --query "id" -o tsv)
# gateway_url=$(az apim show -g $AZURE_RESOURCE_GROUP_NAME -n $AZURE_APIM_NAME --query "gatewayUrl" -o tsv)
# apim_endpoint=$gateway_url/kakao/access-token
# echo "::add-mask::$apim_endpoint"
# echo "APIM_ENDPOINT=$apim_endpoint" >> $GITHUB_ENV
- name: Get SWA token
shell: bash
run: |
swa_token=$(az staticwebapp secrets list -g $AZURE_RESOURCE_GROUP_NAME -n $AZURE_STTAPP_NAME --query "properties.apiKey" -o tsv)
echo "::add-mask::$swa_token"
echo "SWA_TOKEN=$swa_token" >> $GITHUB_ENV
- name: Update appsettings.json
shell: pwsh
run: |
pushd ${{ github.workspace }}/published/${{ inputs.artifact_name }}-web/wwwroot
$(Get-Content -Path ./appsettings.sample.json -Raw) -replace "<AZURE_APIM_NAME>", "${{ env.AZURE_APIM_NAME }}" | `
ConvertFrom-Json | ConvertTo-Json -Depth 10 | `
Out-File -Path ./appsettings.json -Force
popd
# - name: Deploy SWA to Azure
# shell: bash
# run: |
# swa deploy -d ${{ env.SWA_TOKEN }} -a ${{ github.workspace }}/published/${{ inputs.artifact_name }}-web/wwwroot --env default
- name: Deploy SWA to Azure
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ env.SWA_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
skip_app_build: true
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "${{ github.workspace }}/published/${{ inputs.artifact_name }}-web/wwwroot" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######
- name: Update APIM
shell: bash
run: |
sttapp_host=$(az staticwebapp show \
-g ${{ env.AZURE_RESOURCE_GROUP_NAME }} \
-n ${{ env.AZURE_STTAPP_NAME }} \
--query "defaultHostname" -o tsv)
apim_nv=$(az apim nv update \
-g ${{ env.AZURE_RESOURCE_GROUP_NAME }} \
-n ${{ env.AZURE_APIM_NAME }} \
--named-value-id STTAPP_HOST \
--value $sttapp_host)