@@ -87,91 +87,110 @@ jobs:
8787
8888 # Azure login step removed - using storage account key instead
8989
90- - name : Upload to Azure Blob Storage
90+ - name : Install azcopy
91+ run : |
92+ # Download and install azcopy for faster uploads
93+ wget -O azcopy.tar.gz https://aka.ms/downloadazcopy-v10-linux
94+ tar -xf azcopy.tar.gz --strip-components=1
95+ sudo mv azcopy /usr/local/bin/
96+ azcopy --version
97+
98+ - name : Upload to Azure Blob Storage with AzCopy
9199 run : |
92100 echo "Deploying to ${{ needs.determine-environment.outputs.environment }} environment"
101+ echo "Starting high-performance upload of ~60,000 files..."
93102
94- # Upload all files to the $web container using storage account key
95- az storage blob upload-batch \
103+ # Create SAS token for azcopy (more secure than using key directly)
104+ end_date=$(date -u -d "30 minutes" '+%Y-%m-%dT%H:%MZ')
105+ sas_token=$(az storage container generate-sas \
96106 --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
97107 --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
98- --destination '$web' \
99- --source ./build \
100- --overwrite
108+ --name '$web' \
109+ --permissions dlrw \
110+ --expiry $end_date \
111+ --output tsv)
112+
113+ # Use azcopy for parallel uploads (much faster for many files)
114+ azcopy copy "./build/*" \
115+ "https://${{ secrets.STORAGE_ACCOUNT_NAME }}.blob.core.windows.net/\$web?$sas_token" \
116+ --recursive \
117+ --overwrite=true \
118+ --log-level=WARNING \
119+ --cap-mbps=0 \
120+ --block-size-mb=4 \
121+ --include-pattern="*"
122+
123+ echo "Upload completed!"
101124
102- - name : Set blob content types
125+ - name : Set blob content types efficiently
103126 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
127+ echo "Setting content types for web files..."
128+
129+ # Create a properties file for batch operations
130+ cat > set_content_types.sh << 'EOF'
131+ #!/bin/bash
132+
133+ # Function to set content types in parallel
134+ set_content_type() {
135+ local pattern=$1
136+ local content_type=$2
137+
138+ az storage blob list \
139+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
140+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
141+ --container-name '$web' \
142+ --prefix "" \
143+ --query "[?ends_with(name, '$pattern')].name" \
144+ --output tsv | \
145+ xargs -P 10 -I {} az storage blob update \
146+ --account-name ${{ secrets.STORAGE_ACCOUNT_NAME }} \
147+ --account-key ${{ secrets.STORAGE_ACCOUNT_KEY }} \
148+ --container-name '$web' \
149+ --name "{}" \
150+ --content-type "$content_type" \
151+ --output none
152+ }
153+
154+ # Set content types in parallel (10 concurrent operations)
155+ echo "Setting HTML content types..."
156+ set_content_type ".html" "text/html"
157+
158+ echo "Setting CSS content types..."
159+ set_content_type ".css" "text/css"
160+
161+ echo "Setting JS content types..."
162+ set_content_type ".js" "application/javascript"
163+
164+ echo "Setting JSON content types..."
165+ set_content_type ".json" "application/json"
166+
167+ echo "Setting SVG content types..."
168+ set_content_type ".svg" "image/svg+xml"
169+
170+ echo "Setting image content types..."
171+ set_content_type ".png" "image/png"
172+ set_content_type ".jpg" "image/jpeg"
173+ set_content_type ".jpeg" "image/jpeg"
174+ set_content_type ".gif" "image/gif"
175+ set_content_type ".webp" "image/webp"
176+
177+ echo "Setting font content types..."
178+ set_content_type ".woff" "font/woff"
179+ set_content_type ".woff2" "font/woff2"
180+ set_content_type ".ttf" "font/ttf"
181+ set_content_type ".eot" "application/vnd.ms-fontobject"
182+
183+ echo "Content types updated!"
184+ EOF
185+
186+ chmod +x set_content_types.sh
187+ ./set_content_types.sh
188+
189+ - name : Purge CDN endpoint (if configured)
190+ if : ${{ secrets.CDN_ENDPOINT_NAME != '' && secrets.CDN_PROFILE_NAME != '' && secrets.CDN_RESOURCE_GROUP != '' }}
191+ run : |
192+ echo "Note: CDN purge requires Azure login. Skipping CDN purge when using storage key authentication."
193+ echo "To use CDN purge, you'll need to use Azure AD authentication or purge CDN manually."
175194
176195 - name : Display deployment URL
177196 run : |
0 commit comments