-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (54 loc) · 1.69 KB
/
azure-static-web-app.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
name: 🚀 Deploy NextJS starter to Azure Static Web App
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
cache: npm
- name: npm install
run: npm install
- name: npm build
run: npm run build
- name: tar output
run: tar -czvf output.tar.gz ./out/*
- name: upload build artifact
uses: actions/upload-artifact@v4
with:
name: build
path: output.tar.gz
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: ${{ github.event_name == 'pull_request' && 'pr' || 'production' }}
url: ${{ steps.deploy.outputs.url }}
concurrency:
group: ${{ github.event_name == 'pull_request' && 'pr' || 'production' }}
cancel-in-progress: false
steps:
- name: download build artifact
uses: actions/download-artifact@v3
with:
name: build
- name: extract output
run: tar -xzf output.tar.gz
- name: install swa cli
run: npm install -g @azure/static-web-apps-cli
- name: deploy app
id: deploy
run: |
# deploy site with swa
set -o pipefail
swa deploy ./out --deployment-token ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} \
--env ${{ github.event_name == 'pull_request' && 'preview' || 'production' }} 2>&1 | tee deploy.log
url=$(grep 'Project deployed to' deploy.log | awk '{print $5}' | sed 's/\x1b\[[0-9;]*m//g')
echo "url=$url" >> "$GITHUB_OUTPUT"