Skip to content

Commit afe2b19

Browse files
authored
Create main.yml
1 parent b5c54ca commit afe2b19

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy to EC2
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
name: Deploy to Amazon EC2
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v3
16+
17+
- name: Setup SSH
18+
uses: webfactory/ssh-agent@v0.9.0
19+
with:
20+
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
21+
22+
- name: Deploy using Docker Compose
23+
run: |
24+
ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
25+
echo " Navigate to project directory..."
26+
cd /home/ubuntu/TimeFlow
27+
28+
echo "Pull latest images"
29+
docker compose -f docker-compose.prod.yml pull
30+
31+
echo "Stop old containers (if any)"
32+
docker compose -f docker-compose.prod.yml down
33+
34+
echo "Start new containers"
35+
docker compose -f docker-compose.prod.yml up -d
36+
37+
echo "Deploy done"
38+
docker compose -f docker-compose.prod.yml ps
39+
EOF

0 commit comments

Comments
 (0)