Skip to content

Commit e9e6058

Browse files
committed
Update deploy workflow and improve deployment scripts
1 parent ce2cd64 commit e9e6058

File tree

4 files changed

+70
-48
lines changed

4 files changed

+70
-48
lines changed

.deployignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# VCS
2+
.git
3+
.github
4+
5+
# Dependencies
6+
**/node_modules
7+
8+
# Build output
9+
**/.next
10+
**/dist
11+
**/build
12+
**/.turbo
13+
14+
# OS / editor junk
15+
.DS_Store
16+
*.log
17+
18+
# Env (allow prod only if needed)
19+
!.env

.github/workflows/deploy.yml

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
11
name: Deploy to VM
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
7-
workflow_dispatch:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
88

99
jobs:
10-
deploy:
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- name: Checkout repository
15-
uses: actions/checkout@v4
16-
17-
- name: Set release version
18-
run: echo "APP_VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
19-
20-
- name: Set up SSH
21-
uses: webfactory/ssh-agent@v0.8.0
22-
with:
23-
ssh-private-key: ${{ secrets.SSH_KEY }}
24-
25-
- name: Test SSH connection
26-
run: |
27-
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "echo ✅ SSH connection works!"
28-
29-
- name: Copy files to VM
30-
run: |
31-
rsync -avz -e "ssh -o StrictHostKeyChecking=no" . ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/opt/simradar21
32-
33-
- name: Deploy on VM
34-
run: |
35-
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
36-
cd /opt/simradar21
37-
38-
docker compose -f docker/docker-compose.prod.yml down
39-
docker compose -f docker/docker-compose.prod.yml pull || true
40-
docker compose -f docker/docker-compose.prod.yml build --no-cache
41-
docker compose -f docker/docker-compose.prod.yml up -d --remove-orphans
42-
EOF
10+
deploy:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set release version
18+
run: echo "APP_VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
19+
20+
- name: Set up SSH
21+
uses: webfactory/ssh-agent@v0.8.0
22+
with:
23+
ssh-private-key: ${{ secrets.SSH_KEY }}
24+
25+
- name: Test SSH connection
26+
run: |
27+
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "echo ✅ SSH connection works!"
28+
29+
- name: Copy files to VM
30+
run: |
31+
rsync -avz --delete \
32+
--filter=":- .deployignore" \
33+
-e "ssh -o StrictHostKeyChecking=no" \
34+
./ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/opt/simradar21
35+
36+
- name: Deploy on VM
37+
run: |
38+
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
39+
cd /opt/simradar21
40+
41+
docker compose -f docker/docker-compose.prod.yml down
42+
docker compose -f docker/docker-compose.prod.yml pull || true
43+
docker compose -f docker/docker-compose.prod.yml build
44+
docker compose -f docker/docker-compose.prod.yml up -d --remove-orphans
45+
EOF

apps/web/utils/api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export async function fetchApi<T>(endpoint: string, options?: RequestInit): Prom
4444
async function _postApi<T>(endpoint: string, body?: any, options?: RequestInit): Promise<T> {
4545
const isAbsolute = /^https?:\/\//i.test(endpoint);
4646
const url = isAbsolute ? endpoint : `${API_URL}${endpoint}`;
47-
console.log(url);
4847

4948
const response = await fetch(url, {
5049
method: "POST",

docker/clear_db.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,30 @@ export $(grep -v '^#' .env | xargs)
1515
# CONFIGURATION
1616
# -----------------------------
1717
# Docker container names
18-
POSTGRES_CONTAINER="sr24_timescaledb"
19-
REDIS_CONTAINER="sr24_redis"
18+
POSTGRES_CONTAINER="sr21_postgres"
19+
REDIS_CONTAINER="sr21_redis"
2020

2121
# PostgreSQL credentials are now from .env
2222
# PG_USER and PG_DB are automatically set
2323

2424
# -----------------------------
2525
# FUNCTION: Clear PostgreSQL
2626
# -----------------------------
27-
echo "Clearing PostgreSQL database '$POSTGRES_DB' in container '$POSTGRES_CONTAINER'..."
28-
docker exec -i "$POSTGRES_CONTAINER" psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
27+
# echo "Clearing PostgreSQL database '$POSTGRES_DB' in container '$POSTGRES_CONTAINER'..."
28+
# docker exec -i "$POSTGRES_CONTAINER" psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
2929

30-
if [ $? -eq 0 ]; then
31-
echo "PostgreSQL database cleared successfully."
32-
else
33-
echo "Failed to clear PostgreSQL database."
34-
fi
30+
# if [ $? -eq 0 ]; then
31+
# echo "PostgreSQL database cleared successfully."
32+
# else
33+
# echo "Failed to clear PostgreSQL database."
34+
# fi
3535

3636
# -----------------------------
3737
# FUNCTION: Clear Redis
3838
# -----------------------------
3939
echo "Clearing all data in Redis container '$REDIS_CONTAINER'..."
40-
docker exec -i "$REDIS_CONTAINER" redis-cli FLUSHALL
40+
# with password
41+
docker exec -i "$REDIS_CONTAINER" redis-cli -a "$REDIS_PASSWORD" FLUSHALL
4142

4243
if [ $? -eq 0 ]; then
4344
echo "Redis cleared successfully."

0 commit comments

Comments
 (0)