Merge pull request #691 from UKHSA-Internal/changes_to_how_packages_a… #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Dashboard (Static Website) to Sandbox Environment. | |
### | |
on: | |
push: | |
branches: | |
- sandbox | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
name: Deploy Dashboard (Static Website) to Sandbox Environment | |
environment: sandbox | |
steps: | |
- name: Checks out the Repo | |
uses: actions/checkout@v3 | |
- name: Installs and Setup Nodejs Version | |
uses: actions/setup-node@v2.1.5 | |
with: | |
node-version: '14' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' | |
- name : Installs Dependancies | |
run: | | |
npm ci | |
- name : Build | |
env: | |
CI: false | |
BASE_URL: 'https://sandbox.coronavirus.data.gov.uk' | |
MAIN_CDN: 'sandbox.coronavirus.data.gov.uk' | |
DOWNLOADS_CDN: 'sandbox.coronavirus.data.gov.uk' | |
API_ENDPOINT: 'sandbox.coronavirus.data.gov.uk/api' | |
USER_API_ENDPOINT: 'api-sandbox.coronavirus.data.gov.uk' | |
APPINSIGHTS_INSTRUMENTATIONKEY: '0ab69a6e-1f5f-4c00-95a4-805490645471' | |
BUILD_ENV: sandbox | |
NODE_ENV: sandbox | |
run: | | |
npm run build | |
## Generate SAS Token for the $web container | |
- name: Login via Az module | |
uses: azure/login@v1 | |
with: | |
creds: ${{secrets.AZURE_CREDENTIALS}} | |
enable-AzPSSession: true | |
- name: Copy Build Files to $web Container in Static Strorage Account | |
uses: azure/powershell@v1 | |
with: | |
inlineScript: | | |
# Generate SAS token for the $web container | |
$expiry=(Get-Date).AddMinutes(10).ToString("yyyy-MM-ddTHH:mm:ssZ") | |
$sas=$(az storage container generate-sas --name "`$web" --account-name c19dashsbuksfe01static --permissions dlrw --expiry $expiry --auth-mode key -o tsv) | |
# Upload files using the generated SAS token. We are using the sync command of azcopy which removes old files from storage | |
azcopy copy "./build/*" "https://c19dashsbuksfe01static.blob.core.windows.net/%24web?$sas" --recursive --put-md5 | |
azPSVersion: "latest" | |
test: | |
runs-on: ubuntu-latest | |
name: Automated Smoke Test of COVID19 Dashboard Website | |
needs: deploy | |
steps: | |
# ## calls the AIQ-Automation-Covid-Dashboard workflow to run the automated tests | |
- name: Calls AIQ-Automation-Covid-Dashboard workflow to run the automated tests | |
run: | | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.ACCESS_TOKEN }} " \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/UKHSA-Internal/AIQ-Automation-Covid-Dashboard/actions/workflows/CovidDashboard_CI.yml/dispatches \ | |
-d '{"ref":"main","inputs": { "DExecution_Env":"Sandbox", "DScenarioNameTest":"SmokeTests_Scenario" }}' | |
#$accountName = "$(namePrefix)static" | |
#$rgname = "$(AzureResourceGroup)" | |
#$key = Get-AzStorageAccountKey -Name $accountname -ResourceGroupName $rgname | |
#$context = New-AzStorageContext -StorageAccountName $accountName -StorageAccountKey $key[0].Value | |
## List all blob ins $web container | |
#$blobs = Get-AzStorageBlob -Context $context -Container "`$web" -Blob "*" | |
#foreach($blob in $blobs) | |
#{ | |
# if($blob.Name -eq "index.html") | |
# { | |
# # The index.html gets a different cache setting than all the other files | |
# $cacheControl = "no-cache" | |
# } | |
# else | |
# { | |
# $cacheControl = "max-age=604800" | |
# } | |
# $blobName = $blob.Name | |
# Write-Host "Setting CacheControl property on blob $blobName to $cacheControl" | |
# $blob.ICloudBlob.Properties.CacheControl = $cacheControl | |
# # Send the update to the cloud | |
# $blob.ICloudBlob.SetProperties() | |
#} | |
## List all svg image blobs in $web container to change the blob property Content Type to image/svg+xml | |
#$blobs = Get-AzStorageBlob -Context $context -Container "`$web" -Blob "*.svg" | |
#foreach($blob in $blobs) | |
#{ | |
# if($blob.Name -eq "index.html") | |
# { | |
# # The index.html gets a different cache setting than all the other files | |
# $cacheControl = "no-cache" | |
# } | |
# else | |
# { | |
# # Set the cache control and content type of svg image blobs | |
# $cacheControl = "max-age=604800" | |
# $contentType = "image/svg+xml" | |
# } | |
# $blobName = $blob.Name | |
# Write-Host "Setting CacheControl property on blob $blobName to $cacheControl and Content Type to $contentType " | |
# $blob.ICloudBlob.Properties.CacheControl = $cacheControl | |
# $blob.ICloudBlob.Properties.ContentType = $contentType | |
# # Send the update to the cloud | |
# $blob.ICloudBlob.SetProperties() | |
#} | |