-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (74 loc) · 2.12 KB
/
build.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
name: Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build and Test Go Backend
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3
# Step 2: Set up Go environment
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.5 # Adjust this to match your Go version
# Step 3: Cache dependencies
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# Step 4: Install dependencies
- name: Install Go Dependencies
run: go mod tidy
# Step 5: Build the Go project
- name: Build Go Project
run: go build -v ./...
# Step 6: Run tests
- name: Run Go Tests
run: go test -v ./...
lint-frontend:
name: Lint Frontend Code
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3
# Step 2: Set up Node.js (if using linters or build tools like ESLint, Prettier)
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18 # Adjust this to your preferred Node.js version
# Step 3: Install frontend dependencies (optional, if you're using npm/yarn)
- name: Install Frontend Dependencies
run: |
if [ -f package.json ]; then
npm install
fi
# Step 4: Run linters (e.g., ESLint or Prettier)
- name: Lint JavaScript and CSS
run: |
if [ -f package.json ]; then
npm run lint
else
echo "No linting configuration found. Skipping..."
fi
deploy:
name: Deploy Application
runs-on: ubuntu-latest
needs: [build, lint-frontend]
steps:
- name: Deploy to Server
run: |
echo "Add deployment logic here"