-
Notifications
You must be signed in to change notification settings - Fork 9
66 lines (60 loc) · 1.96 KB
/
build-deploy-frontend.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
name: Build and Deploy Frontend to Azure Storage
on:
push:
branches: [ main ]
paths:
- frontend/**
- "!frontend/bicep/**"
workflow_dispatch:
concurrency:
group: "frontend"
cancel-in-progress: true
env:
AZURE_REGION: ${{ vars.AZURE_REGION }}
RESOURCE_GROUP: ${{ vars.RESOURCE_GROUP }}
permissions:
id-token: write
contents: read
jobs:
build-react-app:
uses: ./.github/workflows/build-react-app.yml
with:
upload-artifact-key: website
deploy:
environment: ${{ vars.DEFAULT_ENVIRONMENT }}
needs: build-react-app
runs-on: ubuntu-latest
name: Deploy to azure storage
steps:
- name: Download artifact for deploy
uses: actions/download-artifact@v3
with:
name: website
- name: Azure login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Get frontend storage name
uses: azure/CLI@v1
with:
inlineScript: |
FRONTEND_STORAGE=$(az storage account list -g ${{ env.RESOURCE_GROUP }} -o tsv --query "[?starts_with(name, 'frontendapp')]|[0].name")
echo "FRONTEND_STORAGE=$FRONTEND_STORAGE" >> $GITHUB_ENV
- name: Upload to blob storage
uses: azure/CLI@v1
with:
inlineScript: |
echo Deploying to storage account $FRONTEND_STORAGE
az storage blob upload-batch --account-name $FRONTEND_STORAGE --auth-mode key -d '$web' -s . --overwrite
- name: Purge CDN endpoint
uses: azure/CLI@v1
with:
inlineScript: |
az config set defaults.location=$AZURE_REGION defaults.group=$RESOURCE_GROUP
az cdn endpoint purge --content-paths / --ids $(az cdn endpoint list --profile-name $(az cdn profile list -o tsv --query [0].name) -o tsv --query [0].id)
- name: logout
run: |
az logout
if: always()