@@ -11,58 +11,58 @@ jobs:
11
11
runs-on : ubuntu-latest
12
12
steps :
13
13
- uses : actions/checkout@v4
14
-
14
+
15
15
- name : Setup Node.js
16
16
uses : actions/setup-node@v4
17
17
with :
18
18
node-version : ' 20'
19
-
19
+
20
20
- name : Install pnpm
21
21
uses : pnpm/action-setup@v3
22
22
with :
23
23
version : 8
24
-
24
+
25
25
- name : Get pnpm store directory
26
26
id : pnpm-cache
27
27
shell : bash
28
28
run : |
29
29
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
30
-
30
+
31
31
- uses : actions/cache@v4
32
32
with :
33
33
path : ${{ steps.pnpm-cache.outputs.STORE_PATH }}
34
34
key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
35
35
restore-keys : |
36
36
${{ runner.os }}-pnpm-store-
37
-
37
+
38
38
- name : Install dependencies
39
39
run : pnpm install
40
-
40
+
41
41
- name : Install Playwright system dependencies
42
42
run : |
43
43
sudo apt-get update
44
44
sudo apt-get install -y libgtk-4-1 libgraphene-1.0-0 libwoff1 libevent-2.1-7 libopus0 \
45
45
libharfbuzz-icu0 libsecret-1-0 libhyphen0 libmanette-0.2-0 \
46
46
libgles2 libx264-dev libavif-dev
47
-
47
+
48
48
- name : Install Playwright
49
49
run : pnpm exec playwright install --with-deps
50
-
50
+
51
51
- name : Build shared package
52
52
run : pnpm --filter shared build
53
-
53
+
54
54
- name : Type check
55
55
run : |
56
56
# Skip type checking for now and just build
57
57
pnpm --filter shared build
58
58
pnpm --filter server build --skipLibCheck
59
-
59
+
60
60
- name : Lint
61
61
run : pnpm --filter client lint
62
-
62
+
63
63
- name : End-to-end tests
64
64
run : pnpm e2e
65
-
65
+
66
66
- name : Build
67
67
run : pnpm build
68
68
@@ -75,37 +75,37 @@ jobs:
75
75
packages : write
76
76
steps :
77
77
- uses : actions/checkout@v4
78
-
78
+
79
79
- name : Set up Docker Buildx
80
80
uses : docker/setup-buildx-action@v3
81
-
81
+
82
82
- name : Log in to GitHub Container Registry
83
83
uses : docker/login-action@v3
84
84
with :
85
85
registry : ghcr.io
86
86
username : ${{ github.actor }}
87
87
password : ${{ secrets.GITHUB_TOKEN }}
88
-
88
+
89
89
- name : Set lowercase names
90
90
id : lowercase
91
91
run : |
92
92
echo "owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
93
93
echo "repo=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
94
-
94
+
95
95
- name : Extract metadata for Docker
96
96
id : meta
97
97
uses : docker/metadata-action@v5
98
98
with :
99
99
images : ghcr.io/${{ steps.lowercase.outputs.owner }}/${{ steps.lowercase.outputs.repo }}
100
-
100
+
101
101
- name : Build and push client image
102
102
uses : docker/build-push-action@v5
103
103
with :
104
104
context : .
105
105
push : true
106
106
tags : ghcr.io/${{ steps.lowercase.outputs.owner }}/${{ steps.lowercase.outputs.repo }}/client:latest
107
107
target : client
108
-
108
+
109
109
- name : Build and push server image
110
110
uses : docker/build-push-action@v5
111
111
with :
@@ -114,6 +114,15 @@ jobs:
114
114
tags : ghcr.io/${{ steps.lowercase.outputs.owner }}/${{ steps.lowercase.outputs.repo }}/server:latest
115
115
target : server
116
116
117
+ - name : Copy Nginx config to VPS
118
+ uses : appleboy/scp-action@master
119
+ with :
120
+ host : ${{ secrets.VPS_HOST }}
121
+ username : ${{ secrets.VPS_USERNAME }}
122
+ key : ${{ secrets.VPS_SSH_KEY }}
123
+ source : " nginx/hackops.dracodev.me.conf"
124
+ target : " /tmp"
125
+
117
126
- name : Deploy to VPS
118
127
uses : appleboy/ssh-action@master
119
128
with :
@@ -124,7 +133,7 @@ jobs:
124
133
# Create app directory if it doesn't exist
125
134
mkdir -p ~/hackops-submission
126
135
cd ~/hackops-submission
127
-
136
+
128
137
# Create docker-compose file
129
138
echo 'version: "3.8"' > docker-compose.yml
130
139
echo '' >> docker-compose.yml
@@ -137,6 +146,7 @@ jobs:
137
146
echo ' - NODE_ENV=production' >> docker-compose.yml
138
147
echo ' depends_on:' >> docker-compose.yml
139
148
echo ' - server' >> docker-compose.yml
149
+ echo ' restart: unless-stopped' >> docker-compose.yml
140
150
echo '' >> docker-compose.yml
141
151
echo ' server:' >> docker-compose.yml
142
152
echo ' image: ghcr.io/${{ steps.lowercase.outputs.owner }}/${{ steps.lowercase.outputs.repo }}/server:latest' >> docker-compose.yml
@@ -145,9 +155,45 @@ jobs:
145
155
echo ' environment:' >> docker-compose.yml
146
156
echo ' - NODE_ENV=production' >> docker-compose.yml
147
157
echo ' command: node /app/server/index.js' >> docker-compose.yml
148
-
158
+ echo ' restart: unless-stopped' >> docker-compose.yml
159
+
149
160
# Pull latest images and restart containers
150
161
docker pull ghcr.io/${{ steps.lowercase.outputs.owner }}/${{ steps.lowercase.outputs.repo }}/client:latest
151
162
docker pull ghcr.io/${{ steps.lowercase.outputs.owner }}/${{ steps.lowercase.outputs.repo }}/server:latest
152
163
docker-compose down
153
164
docker-compose up -d
165
+
166
+ # Set up Nginx
167
+ # Install Nginx if not already installed
168
+ if ! command -v nginx &> /dev/null; then
169
+ apt-get update
170
+ apt-get install -y nginx
171
+ fi
172
+
173
+ # Copy Nginx configuration
174
+ cp /tmp/nginx/hackops.dracodev.me.conf /etc/nginx/sites-available/hackops.dracodev.me
175
+
176
+ # Create symbolic link if it doesn't exist
177
+ if [ ! -f /etc/nginx/sites-enabled/hackops.dracodev.me ]; then
178
+ ln -s /etc/nginx/sites-available/hackops.dracodev.me /etc/nginx/sites-enabled/
179
+ fi
180
+
181
+ # Remove default site if it exists
182
+ if [ -f /etc/nginx/sites-enabled/default ]; then
183
+ rm /etc/nginx/sites-enabled/default
184
+ fi
185
+
186
+ # Test Nginx configuration
187
+ nginx -t
188
+
189
+ # Reload Nginx
190
+ systemctl reload nginx
191
+
192
+ # Install Certbot for SSL if not already installed
193
+ if ! command -v certbot &> /dev/null; then
194
+ apt-get update
195
+ apt-get install -y certbot python3-certbot-nginx
196
+ fi
197
+
198
+ # Set up SSL certificate
199
+ certbot --nginx -d hackops.dracodev.me --non-interactive --agree-tos --email [email protected]
0 commit comments