-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (125 loc) · 4.48 KB
/
deploy.yml
File metadata and controls
145 lines (125 loc) · 4.48 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Deploy to Production
on:
release:
types: [published]
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
type: choice
options:
- development
- staging
- production
version:
description: 'Version to deploy'
required: true
type: string
env:
GO_VERSION: '1.24'
jobs:
build-and-package:
name: Build and Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build all binaries
run: |
make build-master
make build-agent
make build-cli
- name: Create deployment package
run: |
VERSION=${{ github.event.inputs.version || github.ref_name }}
tar -czf ffrtmp-${VERSION}.tar.gz bin/ deployment/ ansible/
- name: Upload deployment package
uses: actions/upload-artifact@v4
with:
name: deployment-package
path: ffrtmp-*.tar.gz
deploy-master:
name: Deploy Master Node
needs: build-and-package
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment || 'production' }}
steps:
- uses: actions/checkout@v4
- name: Download deployment package
uses: actions/download-artifact@v4
with:
name: deployment-package
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Run pre-flight checks
run: |
ssh ${{ secrets.MASTER_HOST }} "bash -s" < deployment/checks/preflight-check.sh -- --master
- name: Deploy to master
run: |
VERSION=${{ github.event.inputs.version || github.ref_name }}
scp ffrtmp-${VERSION}.tar.gz ${{ secrets.MASTER_HOST }}:/tmp/
ssh ${{ secrets.MASTER_HOST }} "cd /tmp && tar -xzf ffrtmp-${VERSION}.tar.gz"
ssh ${{ secrets.MASTER_HOST }} "cd /tmp && ./deployment/orchestration/blue-green-deploy.sh --deploy --master --version ${VERSION}"
- name: Health check
run: |
ssh ${{ secrets.MASTER_HOST }} "bash -s" < deployment/checks/health-check.sh -- --master
- name: Switch to new version
run: |
ssh ${{ secrets.MASTER_HOST }} "./deployment/orchestration/blue-green-deploy.sh --switch --master"
- name: Final health check
run: |
ssh ${{ secrets.MASTER_HOST }} "bash -s" < deployment/checks/health-check.sh -- --master
deploy-workers:
name: Deploy Worker Nodes
needs: [build-and-package, deploy-master]
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment || 'production' }}
steps:
- uses: actions/checkout@v4
- name: Download deployment package
uses: actions/download-artifact@v4
with:
name: deployment-package
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Rolling update workers
run: |
VERSION=${{ github.event.inputs.version || github.ref_name }}
./deployment/orchestration/rolling-update.sh \
--workers ${{ secrets.WORKER_HOSTS }} \
--version ${VERSION} \
--master-url ${{ secrets.MASTER_URL }} \
--api-key ${{ secrets.MASTER_API_KEY }} \
--max-parallel 2
notify:
name: Notify Deployment Status
needs: [deploy-master, deploy-workers]
runs-on: ubuntu-latest
if: always()
steps:
- name: Send Slack notification
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
"text": "Deployment ${{ needs.deploy-workers.result == 'success' && 'succeeded' || 'failed' }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*FFmpeg-RTMP Deployment*\nEnvironment: ${{ github.event.inputs.environment || 'production' }}\nVersion: ${{ github.event.inputs.version || github.ref_name }}\nStatus: ${{ needs.deploy-workers.result }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}