-
-
Notifications
You must be signed in to change notification settings - Fork 1
121 lines (101 loc) · 3.51 KB
/
build.yml
File metadata and controls
121 lines (101 loc) · 3.51 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Build
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
environment: Dev
env:
DOCKER_USERNAME: ryaneggz
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
steps:
- name: Checkout code
uses: actions/checkout@v4
###############################################################
## Frontend
###############################################################
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: ./frontend
run: npm ci
- name: Create public directory
working-directory: ./backend
run: mkdir -p src/public
- name: Build frontend
working-directory: ./frontend
run: npm run build
- name: Prune frontend dependencies
working-directory: ./frontend
run: npm prune --production
- name: Save Node dependencies cache
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
###############################################################
## Backend
###############################################################
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
working-directory: ./backend
run: |
env | sort
pip install --upgrade pip
pip install uv
uv sync --frozen --no-cache --no-dev
- name: Build docs
run: |
# Copy docs folder to backend directory
cp -r docs backend/docs
# Change to backend directory
cd backend
# Build docs
uv run mkdocs build --site-dir src/public/docs
# Cleanup docs folder from backend
rm -rf docs || true
- name: Save Python dependencies cache
if: steps.cache-python.outputs.cache-hit != 'true'
id: save-cache-python
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
###############################################################
## Docker
###############################################################
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Build and push Docker image
working-directory: ./backend
run: |
# Use the tag name for the Docker image version
DOCKER_IMAGE=ryaneggz/graphchat:${GITHUB_REF#refs/tags/}
DOCKER_LATEST=ryaneggz/graphchat:latest
echo "Building images: $DOCKER_IMAGE and $DOCKER_LATEST"
docker build --squash -t $DOCKER_IMAGE -t $DOCKER_LATEST .
docker push $DOCKER_IMAGE
docker push $DOCKER_LATEST