-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
28 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
name: Deploy to Droplet | ||
version: '3.8' | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Or your deployment branch | ||
services: | ||
db: | ||
image: postgres:13 | ||
environment: | ||
POSTGRES_PASSWORD: ${DB_PASSWORD} | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
networks: | ||
- my_network | ||
ports: | ||
- "5432:5432" | ||
app: | ||
build: . | ||
ports: | ||
- "3000:3000" # Map the port from the container to the host (adjust if your app uses a different port) | ||
depends_on: | ||
- db | ||
environment: | ||
- DATABASE_URL=postgresql://postgres:${DB_PASSWORD}@db:5432/postgres?connect_timeout=300 | ||
networks: | ||
- my_network | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
volumes: | ||
postgres_data: | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_KEY }} | ||
|
||
- name: Deploy to Droplet | ||
env: | ||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | ||
run: | | ||
ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF' | ||
cd /home/my-app/fiit-mtaa-2024-server/ | ||
git pull | ||
export DB_PASSWORD=${DB_PASSWORD} | ||
docker compose down | ||
docker compose up --build -d | ||
EOF | ||
networks: | ||
my_network: | ||
driver: bridge |