@@ -2,49 +2,70 @@ name: Azure Static Web Apps CI/CD
22
33on :
44 push :
5- branches :
6- - main
5+ branches : [ main ]
76 pull_request :
8- types : [opened, synchronize, reopened, closed]
9- branches :
10- - main
7+ types : [ opened, synchronize, reopened, closed ]
8+ branches : [ main ]
119
1210jobs :
1311 build_and_deploy_job :
1412 if : github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
1513 runs-on : ubuntu-latest
1614 name : Build and Deploy Job
1715 permissions :
18- id-token : write
19- contents : read
16+ id-token : write
17+ contents : read
18+
2019 steps :
21- - uses : actions/checkout@v3
20+ - name : Checkout
21+ uses : actions/checkout@v4
2222 with :
2323 submodules : true
2424 lfs : false
25- - name : Install OIDC Client from Core Package
26- run : npm install @actions/core@1.6.0 @actions/http-client
27- - name : Get Id Token
28- uses : actions/github-script@v6
29- id : idtoken
25+
26+ # ---- Amplify preBuild equivalent: install pnpm + workspace install from repo root
27+ - name : Setup Node
28+ uses : actions/setup-node@v4
29+ with :
30+ node-version : ' 18' # Next 14 safe LTS
31+ cache : ' pnpm'
32+
33+ - name : Setup pnpm
34+ uses : pnpm/action-setup@v4
35+ with :
36+ version : 9
37+
38+ # ---- Amplify cache equivalents
39+ - name : Cache .next and pnpm store
40+ uses : actions/cache@v4
3041 with :
31- script : |
32- const coredemo = require('@actions/core')
33- return await coredemo.getIDToken()
34- result-encoding : string
42+ path : |
43+ packages/frontend/.next/cache
44+ node_modules/.pnpm
45+ .pnpm-store
46+ ~/.pnpm-store
47+ key : ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
48+ restore-keys : |
49+ ${{ runner.os }}-pnpm-
50+
51+ # ---- Build & Deploy (Amplify buildPath=/; then build app)
3552 - name : Build And Deploy
3653 id : builddeploy
3754 uses : Azure/static-web-apps-deploy@v1
3855 with :
3956 azure_static_web_apps_api_token : ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_POND_070533700 }}
40- action : " upload"
41- # ##### Repository/Build Configurations - These values can be configured to match your app requirements. ######
42- # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
43- app_location : " /packages/frontend/" # App source code path
44- api_location : " /api" # Api source code path - optional
45- output_location : " .next" # Built app content directory - optional
46- github_id_token : ${{ steps.idtoken.outputs.result }}
47- # ##### End of Repository/Build Configurations ######
57+ action : upload
58+
59+ # App folder (Amplify appRoot)
60+ app_location : packages/frontend
61+
62+ # SSR/Hybrid Next.js on SWA → leave empty (Amplify artifacts were .next, SWA handles SSR internally)
63+ output_location : " "
64+
65+ # Run install at repo root, then build the app (Amplify preBuild + build)
66+ app_build_command : |
67+ pnpm install --frozen-lockfile
68+ pnpm --filter ./packages/frontend... run build
4869
4970 close_pull_request_job :
5071 if : github.event_name == 'pull_request' && github.event.action == 'closed'
5576 id : closepullrequest
5677 uses : Azure/static-web-apps-deploy@v1
5778 with :
58- action : " close"
79+ action : close
0 commit comments