-
Notifications
You must be signed in to change notification settings - Fork 43
147 lines (112 loc) · 4.33 KB
/
sandbox.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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()
#}