@@ -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