1- name : Build and deploy Docusaurus site to Azure Web App - product-docs-prod
1+ name : Build and deploy Docusaurus site to Azure Blob Storage
22
33on :
44 push :
55 branches :
66 - main
7+ - develop # Add your development branch here
78 workflow_dispatch :
9+ inputs :
10+ environment :
11+ description : ' Environment to deploy to'
12+ required : true
13+ default : ' development'
14+ type : choice
15+ options :
16+ - development
17+ - production
818
919jobs :
20+ determine-environment :
21+ runs-on : ubuntu-latest
22+ outputs :
23+ environment : ${{ steps.set-env.outputs.environment }}
24+ steps :
25+ - name : Determine environment
26+ id : set-env
27+ run : |
28+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
29+ echo "environment=${{ github.event.inputs.environment }}" >> $GITHUB_OUTPUT
30+ elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
31+ echo "environment=production" >> $GITHUB_OUTPUT
32+ else
33+ echo "environment=development" >> $GITHUB_OUTPUT
34+ fi
35+
1036 build :
1137 runs-on : self-hosted
38+ needs : determine-environment
39+ environment : ${{ needs.determine-environment.outputs.environment }}
1240 permissions :
1341 contents : read
1442
@@ -35,46 +63,121 @@ jobs:
3563 npm run build
3664 env :
3765 NODE_OPTIONS : " --max-old-space-size=16384"
38- DOCUSAURUS_URL : " https://product-docs-prod-hdhbe6h2hddcghd7.eastus2-01.azurewebsites.net"
39-
40- - name : Install zip (if needed)
41- run : sudo apt-get update && sudo apt-get install -y zip
42-
43- - name : Zip static files for Azure deployment
44- run : |
45- cd build
46- zip -r ../build.zip *
47- cd ..
66+ DOCUSAURUS_URL : " https://${{ secrets.STORAGE_ACCOUNT_NAME }}.z13.web.core.windows.net"
67+ # Add any other environment-specific build variables here
68+ NODE_ENV : ${{ needs.determine-environment.outputs.environment }}
4869
4970 - name : Upload artifact for deployment
5071 uses : actions/upload-artifact@v4
5172 with :
52- name : build-zip
53- path : build.zip
73+ name : build-output
74+ path : build/
5475
5576 deploy :
5677 runs-on : ubuntu-latest
57- needs : build
58- permissions :
59- id-token : write
60- contents : read
78+ needs : [build, determine-environment]
79+ environment : ${{ needs.determine-environment.outputs.environment }}
6180
6281 steps :
6382 - name : Download build artifact
6483 uses : actions/download-artifact@v4
6584 with :
66- name : build-zip
85+ name : build-output
86+ path : build/
6787
68- - name : Login to Azure
69- uses : azure/login@v2
70- with :
71- client-id : ${{ secrets.AZUREAPPSERVICE_CLIENTID_A214A3C0191244938C1F540AE0784B17 }}
72- tenant-id : ${{ secrets.AZUREAPPSERVICE_TENANTID_5CCF304AF9F843A583AEF7B0F81ECA5F }}
73- subscription-id : ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_46445F312B66482C990DC764E4218175 }}
88+ # Azure login step removed - using storage account key instead
7489
75- - name : Deploy build.zip to Azure Web App
76- uses : azure/webapps-deploy@v3
77- with :
78- app-name : ' product-docs-prod'
79- slot-name : ' Production'
80- package : build.zip
90+ - name : Upload to Azure Blob Storage
91+ run : |
92+ echo "Deploying to ${{ needs.determine-environment.outputs.environment }} environment"
93+
94+ # Upload all files to the $web container using storage account key
95+ az storage blob upload-batch \
96+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
97+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
98+ --destination '$web' \
99+ --source ./build \
100+ --overwrite
101+
102+ - name : Set blob content types
103+ run : |
104+ # Set correct content types for common web files
105+ az storage blob list \
106+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
107+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
108+ --container-name '$web' \
109+ --query "[?ends_with(name, '.html')].name" \
110+ --output tsv | while read -r blob; do
111+ az storage blob update \
112+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
113+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
114+ --container-name '$web' \
115+ --name "$blob" \
116+ --content-type "text/html"
117+ done
118+
119+ az storage blob list \
120+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
121+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
122+ --container-name '$web' \
123+ --query "[?ends_with(name, '.css')].name" \
124+ --output tsv | while read -r blob; do
125+ az storage blob update \
126+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
127+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
128+ --container-name '$web' \
129+ --name "$blob" \
130+ --content-type "text/css"
131+ done
132+
133+ az storage blob list \
134+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
135+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
136+ --container-name '$web' \
137+ --query "[?ends_with(name, '.js')].name" \
138+ --output tsv | while read -r blob; do
139+ az storage blob update \
140+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
141+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
142+ --container-name '$web' \
143+ --name "$blob" \
144+ --content-type "application/javascript"
145+ done
146+
147+ # Set content types for other common file types
148+ az storage blob list \
149+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
150+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
151+ --container-name '$web' \
152+ --query "[?ends_with(name, '.json')].name" \
153+ --output tsv | while read -r blob; do
154+ az storage blob update \
155+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
156+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
157+ --container-name '$web' \
158+ --name "$blob" \
159+ --content-type "application/json"
160+ done
161+
162+ az storage blob list \
163+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
164+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
165+ --container-name '$web' \
166+ --query "[?ends_with(name, '.svg')].name" \
167+ --output tsv | while read -r blob; do
168+ az storage blob update \
169+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
170+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
171+ --container-name '$web' \
172+ --name "$blob" \
173+ --content-type "image/svg+xml"
174+ done
175+
176+ - name : Display deployment URL
177+ run : |
178+ echo "🚀 Deployment complete!"
179+ echo "Environment: ${{ needs.determine-environment.outputs.environment }}"
180+ echo "URL: https://${{ secrets.STORAGE_ACCOUNT_NAME }}.z13.web.core.windows.net"
181+ if [[ -n "${{ secrets.CUSTOM_DOMAIN }}" ]]; then
182+ echo "Custom Domain: ${{ secrets.CUSTOM_DOMAIN }}"
183+ fi
0 commit comments