Skip to content

Commit 0d4f666

Browse files
committed
add docs_build_path and purge the correct cdn path
1 parent c2c0584 commit 0d4f666

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

.github/workflows/docs-build-push.yml

+11-12
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ on:
2020
description: "Directory of built docs files. Hugo default would be `./public/`"
2121
required: true
2222
type: string
23-
cdn_content_path:
24-
description: "The content path to be purged. Change to main docs repo currently requires a full '/*' purge, unless we add logic to determine specifically which docs were updated"
25-
required: true
23+
docs_build_path:
24+
description: "Directory where hugo or sphinx build command should be run from"
25+
required: false
2626
type: string
27+
default: ./
2728
doc_type:
2829
type: string
2930
description: "Type of source docs. Currently supports 'hugo' and 'sphinx'"
@@ -45,7 +46,6 @@ jobs:
4546
PRODUCTION_URL_PATH: ${{inputs.production_url_path}}
4647
PREVIEW_URL_PATH: ${{inputs.preview_url_path}}
4748
DOCS_SOURCE_PATH: ${{inputs.docs_source_path}}
48-
CDN_CONTENT_PATH: ${{inputs.cdn_content_path}}
4949
EVENT_ACTION: ${{github.event.action}}
5050
PR_MERGED: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
5151
concurrency:
@@ -111,11 +111,13 @@ jobs:
111111

112112
- name: Build Hugo for PR preview
113113
if: inputs.doc_type == 'hugo' && (github.event.action == 'synchronize' || github.event.action == 'opened')
114+
working-directory: ${{inputs.docs_build_path}}
114115
run: |
115116
hugo mod get -v "$THEME_MODULE@v$THEME_VERSION"
116117
hugo --gc -e production --baseURL="https://${{steps.keyvault.outputs.previewHostname}}$PREVIEW_URL_PATH$PR_NUMBER"
117118
118119
- name: Build Hugo for production
120+
working-directory: ${{inputs.docs_build_path}}
119121
if: inputs.doc_type == 'hugo' && env.PR_MERGED == 'true'
120122
run: |
121123
hugo mod get "$THEME_MODULE@v$THEME_VERSION"
@@ -140,6 +142,7 @@ jobs:
140142
chmod 700 /home/runner/.gnupg
141143
142144
- name: Build Sphinx for PR preview and production
145+
working-directory: ${{inputs.docs_build_path}}
143146
if: inputs.doc_type == 'sphinx'
144147
run: |
145148
make deploy
@@ -149,20 +152,16 @@ jobs:
149152
if: github.event.action == 'synchronize' || github.event.action == 'opened'
150153
with:
151154
inlineScript: |
152-
az storage blob upload-batch -s $DOCS_SOURCE_PATH -d '$web' --destination-path "dev/${{github.repository}}/previews/${PR_NUMBER}" --account-name ${{steps.keyvault.outputs.accountName}} --overwrite --auth-mode login
155+
cd ${{inputs.docs_build_path}} && az storage blob upload-batch -s $DOCS_SOURCE_PATH -d '$web' --destination-path "dev/${{github.repository}}/previews/${PR_NUMBER}" --account-name ${{steps.keyvault.outputs.accountName}} --overwrite --auth-mode login
156+
az cdn endpoint purge --content-paths $PREVIEW_URL_PATH/* --profile-name ${{steps.keyvault.outputs.cdnProfileName}} --name ${{steps.keyvault.outputs.cdnName}} --resource-group ${{steps.keyvault.outputs.resourceGroupName}}
153157
154158
- name: Azure upload for production
155159
uses: azure/cli@965c8d7571d2231a54e321ddd07f7b10317f34d9 # v2.0.0
156160
if: env.PR_MERGED == 'true'
157161
with:
158162
inlineScript: |
159-
az storage blob upload-batch -s $DOCS_SOURCE_PATH -d '$web' --destination-path "prod/${{github.repository}}/latest/" --account-name ${{steps.keyvault.outputs.accountName}} --overwrite --auth-mode login
160-
161-
- name: Azure purge CDN endpoint
162-
uses: azure/cli@965c8d7571d2231a54e321ddd07f7b10317f34d9 # v2.0.0
163-
with:
164-
inlineScript: |
165-
az cdn endpoint purge --content-paths $CDN_CONTENT_PATH --profile-name ${{steps.keyvault.outputs.cdnProfileName}} --name ${{steps.keyvault.outputs.cdnName}} --resource-group ${{steps.keyvault.outputs.resourceGroupName}}
163+
cd ${{inputs.docs_build_path}} && az storage blob upload-batch -s $DOCS_SOURCE_PATH -d '$web' --destination-path "prod/${{github.repository}}/latest/" --account-name ${{steps.keyvault.outputs.accountName}} --overwrite --auth-mode login
164+
az cdn endpoint purge --content-paths $PRODUCTION_URL_PATH/* --profile-name ${{steps.keyvault.outputs.cdnProfileName}} --name ${{steps.keyvault.outputs.cdnName}} --resource-group ${{steps.keyvault.outputs.resourceGroupName}}
166165
167166
- name: Azure logout
168167
run: |

0 commit comments

Comments
 (0)