Skip to content

Commit 04f76b7

Browse files
fix(eds-core-react): correct azure cli to purge cache (#4240)
1 parent 6a5ef2c commit 04f76b7

2 files changed

Lines changed: 53 additions & 12 deletions

File tree

.github/workflows/_purge_cdn.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@ jobs:
2828
client-id: d58b2e85-2d34-4cdb-ad70-5f2b767dd8e2
2929
tenant-id: 3aa4a235-b6e2-48d5-9195-7fcf05b459b0
3030
allow-no-subscriptions: true
31+
- name: Ensure Front Door CLI extension
32+
run: |
33+
az extension add -n front-door || az extension update -n front-door
3134
- name: Purge CDN endpoint 🚮
3235
if: inputs.endpoint == 'artefacts'
33-
uses: azure/CLI@v1
36+
uses: azure/cli@v2
3437
with:
3538
inlineScript: |
36-
az cdn endpoint purge --content-paths "/*" --profile-name ${{ env.AZURE_CDN_PROFILE_NAME }} --name ${{ env.AZURE_CDN_ENDPOINT_NAME }} --resource-group ${{ env.AZURE_RESOURCE_GROUP }}
39+
az afd endpoint purge --content-paths "/*" --profile-name ${{ env.AZURE_CDN_PROFILE_NAME }} --endpoint-name ${{ env.AZURE_CDN_ENDPOINT_NAME }} --resource-group ${{ env.AZURE_RESOURCE_GROUP }}
3740
- name: Purge Storybook endpoint 🚮
3841
if: inputs.endpoint == 'storybook'
39-
uses: azure/CLI@v1
42+
uses: azure/cli@v2
4043
with:
4144
inlineScript: |
42-
az cdn endpoint purge --content-paths "/*" --profile-name ${{ env.AZURE_CDN_PROFILE_NAME }} --name ${{ env.AZURE_STORYBOOK_ENDPOINT_NAME }} --resource-group ${{ env.AZURE_RESOURCE_GROUP }}
45+
az afd endpoint purge --content-paths "/*" --profile-name ${{ env.AZURE_CDN_PROFILE_NAME }} --endpoint-name ${{ env.AZURE_STORYBOOK_ENDPOINT_NAME }} --resource-group ${{ env.AZURE_RESOURCE_GROUP }}
4346
- name: logout 🔓
4447
run: |
4548
az logout

.github/workflows/publish_storybook.yaml

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,69 @@ jobs:
100100
tenant-id: 3aa4a235-b6e2-48d5-9195-7fcf05b459b0
101101
allow-no-subscriptions: true
102102

103-
- name: Delete old index.json to force overwrite 🗑️
103+
- name: Delete all existing blobs to ensure clean deployment 🗑️
104104
env:
105105
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.AZ_STORYBOOK_CONNECTION_STRING }}
106106
run: |
107-
echo "Deleting old index.json..."
108-
az storage blob delete \
107+
set -euo pipefail
108+
echo "Checking existing blobs in container '\$web'..."
109+
BLOB_COUNT=$(az storage blob list \
109110
--container-name '$web' \
110-
--name index.json \
111-
--connection-string "$AZURE_STORAGE_CONNECTION_STRING" || echo "index.json didn't exist, continuing..."
111+
--connection-string "$AZURE_STORAGE_CONNECTION_STRING" \
112+
--query 'length(@)' \
113+
--output tsv)
114+
115+
if [ "$BLOB_COUNT" -eq 0 ]; then
116+
echo "Container already empty."
117+
else
118+
echo "Deleting $BLOB_COUNT blobs..."
119+
az storage blob delete-batch \
120+
--source '$web' \
121+
--pattern "*" \
122+
--connection-string "$AZURE_STORAGE_CONNECTION_STRING" \
123+
--output none
124+
echo "Deletion request submitted."
125+
fi
126+
127+
REMAINING=$(az storage blob list \
128+
--container-name '$web' \
129+
--connection-string "$AZURE_STORAGE_CONNECTION_STRING" \
130+
--query 'length(@)' \
131+
--output tsv)
132+
133+
echo "✅ Blob deletion completed. Remaining blobs: $REMAINING"
112134
113135
- name: Deploy to Azure Blob Storage 🚀
114136
id: deploy-website
115137
env:
116138
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.AZ_STORYBOOK_CONNECTION_STRING }}
117139
run: |
140+
set -euo pipefail
118141
echo "Deploying to Azure Blob Storage..."
119142
143+
# Verify source directory exists and has content
144+
if [ ! -d "packages/eds-core-react/storybook-build" ]; then
145+
echo "❌ Error: storybook-build directory not found"
146+
exit 1
147+
fi
148+
149+
FILE_COUNT=$(find packages/eds-core-react/storybook-build -type f | wc -l)
150+
echo "Uploading $FILE_COUNT files..."
151+
120152
az storage blob upload-batch \
121153
--destination '$web' \
122154
--source packages/eds-core-react/storybook-build \
123155
--overwrite \
124156
--connection-string "$AZURE_STORAGE_CONNECTION_STRING"
125157
126-
echo "✅ Deployment completed successfully"
158+
# Verify upload
159+
UPLOADED=$(az storage blob list \
160+
--container-name '$web' \
161+
--connection-string "$AZURE_STORAGE_CONNECTION_STRING" \
162+
--query 'length(@)' \
163+
--output tsv)
164+
165+
echo "✅ Deployment completed successfully. Total blobs in container: $UPLOADED"
127166
128167
- name: logout 🔓
129168
run: az logout
@@ -137,11 +176,10 @@ jobs:
137176
if: failure()
138177

139178
purge-cdn:
140-
if: github.event.inputs.environment == 'production'
141179
needs: [publish-storybook]
142180
name: Purge cdn
143181
uses: ./.github/workflows/_purge_cdn.yaml
144182
secrets: inherit
145183
with:
146-
environment: production
184+
environment: ${{ github.event.inputs.environment || 'development' }}
147185
endpoint: storybook

0 commit comments

Comments
 (0)