-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (39 loc) · 1.45 KB
/
deploy.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
name: Deploy to Droplet
on:
push:
branches:
- main # Or your deployment branch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Prepare Deployment Environment
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF'
cd /home/my-app/fiit-mtaa-2024-server/
git pull
EOF
- name: Create .env file on Droplet
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF'
cd /home/my-app/fiit-mtaa-2024-server/
echo "Creating .env file..."
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" > .env
echo "PORT=3000" >> .env
echo "DATABASE_PORT=5432" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
echo "DATABASE_URL=postgresql://postgres:${DB_PASSWORD}@localhost:${DATABASE_PORT}/postgres?connect_timeout=300" >> .env
EOF
- name: Deploy with Docker Compose
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF'
cd /home/my-app/fiit-mtaa-2024-server/
docker compose down
docker compose up --build -d
EOF