-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (60 loc) · 2.14 KB
/
publish.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
name: Deploy website
on:
workflow_dispatch:
# Uncomment this to let the workflow run on every push to main:
# push:
# branches: [ main ]
# IMPORTANT: You need to set up a repo secret called DEPLOY_SAS_URL.
# Here's how: https://github.com/marketplace/actions/deploy-to-azure-storage#how-to-get-a-sas-url-and-save-it
env:
# To purge Azure CDN after deployment, set the following values and a repo secret called AZURE_CREDENTIALS.
# Here's how: https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-static-site-github-actions#generate-deployment-credentials
# Otherwise, just delete all of these.
ENABLE_CDN_PURGE: false
AZURE_RESOURCE_GROUP: MyResourceGroup
AZURE_CDN_PROFILE: MyCDNProfile
AZURE_CDN_ENDPOINT: mycdnendpoint
jobs:
build-and-deploy:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- name: Check out the code from GitHub
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build website
run: |
npm install
npm run build
- name: Create redirects
uses: TravisSpomer/[email protected]
with:
output-path: build
routes: static/staticwebapp.config.json
canonical-url: https://EXAMPLE.z22.web.core.windows.net/
- name: Deploy to Azure
uses: TravisSpomer/[email protected]
with:
source-path: build
sas-url: ${{ secrets.DEPLOY_SAS_URL }}
immutable: "*.js;*.css"
- name: Log in to Azure
if: env.ENABLE_CDN_PURGE == 'true'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Purge CDN
if: env.ENABLE_CDN_PURGE == 'true'
uses: azure/CLI@v1
with:
inlineScript: |
az cdn endpoint purge --no-wait --content-paths "/*" --resource-group "${{ env.AZURE_RESOURCE_GROUP }}" --profile-name "${{ env.AZURE_CDN_PROFILE }}" --name "${{ env.AZURE_CDN_ENDPOINT }}"
- name: Log out of Azure
if: env.ENABLE_CDN_PURGE == 'true'
uses: azure/CLI@v1
with:
inlineScript: |
az logout