-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (76 loc) · 2.47 KB
/
ci.yml
File metadata and controls
91 lines (76 loc) · 2.47 KB
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
name: Continuous Integration - Backend & Frontend
on:
push:
branches:
- master
paths:
- "backend/**"
- "frontend/**"
pull_request:
branches:
- master
paths:
- "backend/**"
- "frontend/**"
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
outputs:
backend_changed: ${{ steps.backend-changes.outputs.any_changed }}
frontend_changed: ${{ steps.frontend-changes.outputs.any_changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Detect backend changes
id: backend-changes
uses: tj-actions/changed-files@v45
with:
files: backend/**
- name: Detect frontend changes
id: frontend-changes
uses: tj-actions/changed-files@v45
with:
files: frontend/**
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.14.0
- name: Install dependencies (from workspace root)
run: pnpm install
- name: Generate Prisma Client
if: steps.backend-changes.outputs.any_changed == 'true'
run: pnpm --filter backend exec prisma generate
- name: Lint and Build Backend
if: steps.backend-changes.outputs.any_changed == 'true'
run: |
pnpm --filter backend lint
pnpm --filter backend build
- name: Lint and Build Frontend
if: steps.frontend-changes.outputs.any_changed == 'true'
run: |
pnpm --filter frontend lint
pnpm --filter frontend build
build-and-push-docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: build-and-test
if: needs.build-and-test.outputs.backend_changed == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME}}/chess-app-backend:latest -f backend/Dockerfile .
docker push ${{ secrets.DOCKER_USERNAME }}/chess-app-backend:latest