File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments