Skip to content

Commit 627814c

Browse files
authoredJul 12, 2024··
Merge pull request #17 from daffahilmyf/daffa/gh-action
[ADD] Github action workflow for build frontend, functions and verify contracts
2 parents f6bf31e + 1850b37 commit 627814c

File tree

4 files changed

+174
-10
lines changed

4 files changed

+174
-10
lines changed
 

‎.github/workflows/build_frontend.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Frontend
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["Contract"]
7+
types:
8+
- completed
9+
push:
10+
branches: ["main", "stage"]
11+
pull_request:
12+
branches: ["main", "stage"]
13+
14+
defaults:
15+
run:
16+
working-directory: frontend
17+
18+
jobs:
19+
lint:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: 20
29+
30+
- name: Cache node modules
31+
id: cache-npm
32+
uses: actions/cache@v3
33+
env:
34+
cache-name: cache-npm
35+
with:
36+
path: ~/.npm
37+
key: firebase-frontend-${{ runner.os }}-${{ hashFiles('frontend/package-lock.json') }}
38+
39+
- name: Install Dependencies
40+
run: npm ci
41+
42+
- name: Lint Frontend
43+
run: npm run lint
44+
45+
build:
46+
runs-on: ubuntu-latest
47+
needs: lint
48+
steps:
49+
50+
- name: Checkout Code
51+
uses: actions/checkout@v3
52+
53+
- name: Set up Node.js
54+
uses: actions/setup-node@v3
55+
with:
56+
node-version: 20
57+
58+
- name: Cache node modules
59+
id: cache-npm
60+
uses: actions/cache@v3
61+
env:
62+
cache-name: cache-npm
63+
with:
64+
path: ~/.npm
65+
key: firebase-frontend-${{ runner.os }}-${{ hashFiles('frontend/package-lock.json') }}
66+
67+
- name: Install Dependencies
68+
run: npm ci
69+
70+
- name: Build Frontend
71+
run: npm run build --if-present

‎.github/workflows/build_functions.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Functions
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["Contract"]
7+
types:
8+
- completed
9+
push:
10+
branches: ["main", "stage"]
11+
pull_request:
12+
branches: ["main", "stage"]
13+
14+
defaults:
15+
run:
16+
working-directory: functions
17+
18+
jobs:
19+
lint:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: 20
29+
30+
- name: Cache node modules
31+
id: cache-npm
32+
uses: actions/cache@v3
33+
env:
34+
cache-name: cache-npm
35+
with:
36+
path: ~/.npm
37+
key: firebase-functions-${{ runner.os }}-${{ hashFiles('functions/package-lock.json') }}
38+
39+
- name: Install Dependencies
40+
run: npm ci
41+
42+
- name: Lint functions
43+
run: npm run lint
44+
45+
build:
46+
runs-on: ubuntu-latest
47+
needs: lint
48+
steps:
49+
50+
- name: Checkout Code
51+
uses: actions/checkout@v3
52+
53+
- name: Set up Node.js
54+
uses: actions/setup-node@v3
55+
with:
56+
node-version: 20
57+
58+
- name: Cache node modules
59+
id: cache-npm
60+
uses: actions/cache@v3
61+
env:
62+
cache-name: cache-npm
63+
with:
64+
path: ~/.npm
65+
key: firebase-functions-${{ runner.os }}-${{ hashFiles('functions/package-lock.json') }}
66+
67+
- name: Install Dependencies
68+
run: npm ci
69+
70+
- name: Build Functions
71+
run: npm run build --if-present

‎.github/workflows/verify_contract.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Contract
2+
3+
on:
4+
push:
5+
branches: ["main", "stage"]
6+
pull_request:
7+
branches: ["main", "stage"]
8+
9+
jobs:
10+
check-contracts:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '20'
21+
22+
- name: Verify frontend contracts folder
23+
run: |
24+
diff -r --exclude=node_modules --exclude=.eslintrc.js --exclude=.gitignore --exclude=package-lock.json --exclude=package.json --exclude=tsconfig.json contracts frontend/src/contracts || exit 1
25+
26+
- name: Verify functions contracts folder
27+
run: |
28+
diff -r --exclude=node_modules --exclude=.eslintrc.js --exclude=.gitignore --exclude=package-lock.json --exclude=package.json --exclude=tsconfig.json contracts functions/src/contracts || exit 1

‎sync.bat

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
@echo off
22

3-
rem Creating target directory if not exists
3+
rem Creating target directories if they don't exist
44
mkdir frontend\src\contracts
55
mkdir functions\src\contracts
66

7-
rem Loop through directories in contracts folder and copy them to frontend\src\contracts
7+
rem Loop through directories in contracts folder and copy them to target directories, excluding node_modules
88
for /D %%i in (contracts\*) do (
9-
if not "%%i"=="contracts\node_modules" (
9+
if /I not "%%~nxi"=="node_modules" (
1010
robocopy "%%i" "frontend\src\contracts\%%~nxi" /E > nul
11-
)
12-
)
13-
14-
rem Loop through directories in contracts folder and copy them to functions\src\contracts
15-
for /D %%i in (contracts\*) do (
16-
if not "%%i"=="contracts\node_modules" (
1711
robocopy "%%i" "functions\src\contracts\%%~nxi" /E > nul
1812
)
19-
)
13+
)

0 commit comments

Comments
 (0)
Please sign in to comment.