Skip to content

Commit 75844d0

Browse files
committed
Add ci.yml file for workflow
1 parent 69a43e0 commit 75844d0

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
13+
jobs:
14+
# Job for building the backend (Go)
15+
backend:
16+
name: Build Backend (Go)
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
# Step 1: Checkout the code
21+
- name: Checkout Code
22+
uses: actions/checkout@v3
23+
24+
# Step 2: Set up Go environment
25+
- name: Set up Go
26+
uses: actions/setup-go@v4
27+
with:
28+
go-version: '1.20'
29+
30+
# Step 3: Cache Go modules for faster builds
31+
- name: Cache Go Modules
32+
uses: actions/cache@v3
33+
with:
34+
path: ~/go/pkg/mod
35+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
36+
restore-keys: |
37+
${{ runner.os }}-go-
38+
39+
# Step 4: Install Go dependencies
40+
- name: Install Go Dependencies
41+
run: go mod tidy
42+
43+
# Step 5: Build the Go application
44+
- name: Build Go Application
45+
run: go build -o app ./main.go
46+
47+
# Job for building the frontend (React)
48+
frontend:
49+
name: Build Frontend (React)
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
# Step 1: Checkout the code
54+
- name: Checkout Code
55+
uses: actions/checkout@v3
56+
57+
# Step 2: Set up Node.js environment
58+
- name: Set up Node.js
59+
uses: actions/setup-node@v3
60+
with:
61+
node-version: '18'
62+
63+
# Step 3: Cache Node.js dependencies
64+
- name: Cache Node.js Modules
65+
uses: actions/cache@v3
66+
with:
67+
path: client/node_modules
68+
key: ${{ runner.os }}-node-${{ hashFiles('client/package-lock.json') }}
69+
restore-keys: |
70+
${{ runner.os }}-node-
71+
72+
# Step 4: Install frontend dependencies
73+
- name: Install Dependencies
74+
working-directory: ./client
75+
run: npm install
76+
77+
# Step 5: Build for production
78+
- name: Build Frontend
79+
working-directory: ./client
80+
run: npm run build

0 commit comments

Comments
 (0)