-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (60 loc) · 2.26 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.
# Run: az ad sp create-for-rbac --role contributor --scopes /subscriptions/[your subscription ID]/resourceGroups/[CDN resource group] --sdk-auth
# (You may need to install the Azure CLI (or run "az upgrade") and "az login" before that command.)
# Copy the JSON from the output into the secret.
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/create-redirects@v1.1.0
# with:
# output-path: build
# routes: staticwebapp.config.json
# canonical-url: https://www.example.com
- name: Deploy to Azure
uses: TravisSpomer/deploy-to-azure-storage@v1.4.0
with:
source-path: build
sas-url: ${{ secrets.DEPLOY_SAS_URL }}
- 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