Skip to content

Commit e35115c

Browse files
authored
Merge pull request #5 from Health-Informatics-UoN/create_gh_workflow
Create github workflows for build and deploy
2 parents 0a054d6 + edc2187 commit e35115c

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build WebApp
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- .
8+
- .github/workflows/omop-case-reports.yml
9+
10+
env:
11+
AZURE_WEBAPP_PACKAGE_PATH: .
12+
NODE_VERSION: 24
13+
14+
jobs:
15+
build:
16+
name: Build Web App
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Use Node.js ${{ env.NODE_VERSION }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ env.NODE_VERSION }}
25+
26+
- name: npm install and build
27+
run: |
28+
npm i --workspaces=false
29+
working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
30+
31+
- name: Cache .next/cache
32+
uses: actions/cache@v3
33+
env:
34+
cache-name: cache-node-modules
35+
with:
36+
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/.next/cache
37+
key: nextjs | $(Agent.OS) | ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/package-lock.json
38+
39+
- name: Build
40+
run: npm run build --workspaces=false
41+
working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Publish and Deploy WebApp
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
AZURE_WEBAPP_PACKAGE_PATH: .
10+
NODE_VERSION: 24
11+
12+
jobs:
13+
publish_WebApp:
14+
name: Publish Web App
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Use Node.js ${{ env.NODE_VERSION }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ env.NODE_VERSION }}
23+
24+
- name: npm install and build
25+
run: |
26+
npm i --workspaces=false
27+
working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
28+
29+
- name: Cache .next/cache
30+
uses: actions/cache@v3
31+
env:
32+
cache-name: cache-node-modules
33+
with:
34+
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/.next/cache
35+
key: nextjs | $(Agent.OS) | ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/package-lock.json
36+
37+
- name: Build
38+
run: npm run build --workspaces=false
39+
working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
40+
41+
- name: Copy Static Assets
42+
run: |
43+
cp -r .next/static .next/standalone/.next/
44+
cp -r public .next/standalone/
45+
working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
46+
47+
- name: Publish webapp artifact
48+
uses: actions/upload-artifact@v4
49+
with:
50+
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/.next/standalone
51+
name: frontendwebapp
52+
include-hidden-files: true
53+
54+
# Deploy Production
55+
deploy-prod:
56+
name: Deploy to Appservice
57+
runs-on: ubuntu-latest
58+
environment: production
59+
needs:
60+
- publish_WebApp
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Download artifact from build job
65+
uses: actions/download-artifact@v4
66+
with:
67+
path: frontendwebapp
68+
name: frontendwebapp
69+
70+
- name: Deploy to Azure WebApp
71+
uses: azure/webapps-deploy@v2
72+
with:
73+
app-name: ${{ env.AZURE_WEBAPP_FRONTEND_NAME }}
74+
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
75+
package: ${{ github.workspace }}/frontendwebapp

0 commit comments

Comments
 (0)