-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (51 loc) · 1.87 KB
/
cd.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
48
49
50
51
52
53
54
55
56
57
58
59
name: CD Pipeline
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Notify Telex - Deployment Started
run: |
curl -X POST -H "Content-Type: application/json" -d '{
"event_name": "cd_pipeline",
"username": "GitHub Actions",
"status": "in_progress",
"message": "🚀 Deployment started for commit ${{ github.sha }}."
}' ${{ secrets.TELEX_WEBHOOK_URL }}
- name: Setup SSH Key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/ec2_key.pem
chmod 600 ~/.ssh/ec2_key.pem
- name: Deploy to EC2
run: |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/ec2_key.pem ec2-user@${{ secrets.SSH_HOST }} << 'EOF'
cd /home/ec2-user/interval-custom-integration-task-prioritization
git pull origin main
source venv/bin/activate
pip install -r requirements.txt
sudo systemctl restart fastapi
EOF
- name: Notify Telex - Deployment Successful
if: success()
run: |
curl -X POST -H "Content-Type: application/json" -d '{
"event_name": "cd_pipeline",
"username": "GitHub Actions",
"status": "success",
"message": "✅ Deployment successful for commit ${{ github.sha }}."
}' ${{ secrets.TELEX_WEBHOOK_URL }}
- name: Notify Telex - Deployment Failed
if: failure()
run: |
curl -X POST -H "Content-Type: application/json" -d '{
"event_name": "cd_pipeline",
"username": "GitHub Actions",
"status": "failure",
"message": "❌ Deployment failed for commit ${{ github.sha }}."
}' ${{ secrets.TELEX_WEBHOOK_URL }}