-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (53 loc) · 2.36 KB
/
deploy.yml
File metadata and controls
61 lines (53 loc) · 2.36 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
name: Deploy AlphaLLM via SFTP
# This workflow uploads the entire repository to a remote server using SFTP.
# First we need to update the prod branch using dev branch,
# this is manually done to avoid accidental deployments during development.
# Then we can trigger the second part when ready, which will upload the code to the server.
on:
# Trigger manually from the Actions tab
workflow_dispatch:
push:
branches:
- prod
jobs:
sync-and-deploy:
name: Sync Dev to Prod and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Merge dev into prod
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout prod
git merge origin/dev --no-ff -m "Auto-merge dev into prod for deployment"
git push origin prod
- name: Stop Bot via API
run: |
curl -X POST ${{ secrets.REMOTE_HOST }}:${{ secrets.REMOTE_CONTROL_PORT }}/stop \
-H "X-API-KEY: ${{ secrets.REMOTE_CONTROL_API_KEY }}" \
--insecure
- name: SFTP uploader
uses: wangyucode/sftp-upload-action@v3
with:
host: ${{ secrets.SFTP_HOST }}
port: ${{ secrets.SFTP_PORT }}
username: ${{ secrets.SFTP_USERNAME }}
password: ${{ secrets.SFTP_PASSWORD }}
localDir: "."
remoteDir: "/"
exclude: ".git/,.github/,.vscode/,*-sample.*,*.sh,**/.*,README.md,LICENSE"
concurrency: 10
forceUpload: false
- name: Start/Restart Bot via API
run: |
# Tentative de redémarrage avec retry car l'API peut mettre quelques secondes à être prête
for i in {1..5}; do
curl -X POST ${{ secrets.REMOTE_HOST }}:${{ secrets.REMOTE_CONTROL_PORT }}/restart \
-H "X-API-KEY: ${{ secrets.REMOTE_CONTROL_API_KEY }}" \
--insecure && break || sleep 5
done