-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (117 loc) · 3.75 KB
/
deploy-website.yml
File metadata and controls
134 lines (117 loc) · 3.75 KB
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
name: Deploy Website to Azure
on:
push:
branches:
- master
paths:
- "website/**"
- ".github/workflows/deploy-website.yml"
pull_request:
paths:
- "website/**"
- ".github/workflows/deploy-website.yml"
workflow_dispatch:
permissions:
contents: read
pull-requests: write
env:
AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
ENVIRONMENT: prod
REGION_ABBR: san
LOCATION: eastus2
jobs:
build_and_deploy:
name: Build and Deploy Next.js Website
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: website/package-lock.json
- name: Install dependencies
working-directory: website
run: npm ci
- name: Build Next.js app
working-directory: website
run: npm run build
env:
NODE_ENV: production
- name: Deploy to Azure Static Web Apps
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "website/out"
skip_app_build: true
skip_api_build: true
# PR validation - build only, no deploy
validate_pr:
name: Validate Website Build (PR)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: website/package-lock.json
- name: Install dependencies
working-directory: website
run: npm ci
- name: Build Next.js app
working-directory: website
run: npm run build
env:
NODE_ENV: production
- name: Validate build output
run: |
echo "✅ Website build successful!"
if [ -d "website/out" ]; then
ls -la website/out/
if [ -f "website/out/index.html" ] || [ -d "website/out/index" ]; then
echo "✅ Build output validated - index found"
else
echo "::warning::index.html not found but build completed"
fi
else
echo "Note: Output directory 'website/out' not found - Next.js may use different output config"
fi
deploy_infrastructure:
name: Deploy Azure Infrastructure
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create Resource Group
run: |
az group create \
--name "${{ env.ENVIRONMENT }}-rg-${{ env.REGION_ABBR }}-codeflow" \
--location "${{ env.LOCATION }}" \
--output none
- name: Deploy Bicep Template
run: |
az deployment group create \
--resource-group "${{ env.ENVIRONMENT }}-rg-${{ env.REGION_ABBR }}-codeflow" \
--template-file orchestration/infrastructure/bicep/website.bicep \
--parameters @orchestration/infrastructure/bicep/website-parameters.json \
--parameters regionAbbr=${{ env.REGION_ABBR }}