-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (106 loc) · 3.13 KB
/
ci-cd.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
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: CI CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
cache: maven
- name: Generate parser source code
run: npm run gen-parser
- run: npm ci
- run: npm test
- name: Builds the app for production
run: npm run build
- name: Upload production build
uses: actions/upload-artifact@v4
with:
name: build
if-no-files-found: error
path: build
retention-days: 1
integration-test:
needs: [ build ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, windows-latest ]
browser: [ chrome ]
include:
- os: windows-latest
browser: edge
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Download production build
uses: actions/download-artifact@v2
with:
name: build
path: build
- name: integration test
uses: cypress-io/github-action@v2
with:
start: npm run start:ci
browser: ${{ matrix.browser }}
deploy:
if: ${{ github.event_name == 'release' }}
needs: [ integration-test ]
runs-on: ubuntu-latest
steps:
- name: Download production build
uses: actions/download-artifact@v2
with:
name: build
path: build
- name: Display structure of downloaded files
run: ls -R
working-directory: build
- name: Checkout my GitHub Page
uses: actions/checkout@v4
with:
repository: ZengLawrence/ZengLawrence.github.io
ref: main
token: ${{ secrets.MY_GITHUB_PAGE_PAT }}
path: github-page
- name: Display structure of my GitHub Page
run: ls -R
working-directory: github-page
- name: Remove diet-diary dir
run: git rm -r project/diet-diary/v1/
working-directory: github-page
- name: Copy build dir to diet-diary dir
run: cp -r ../build/ project/diet-diary/v1
working-directory: github-page
- name: Publish to my GitHub page
run: |
git add --all
git diff --stat
git config user.name Lawrence Zeng
git config user.email [email protected]
git commit -m "Production release of Diet Diary ${{ github.ref }}"
git push
working-directory: github-page