File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5656 uses : softprops/action-gh-release@v2
5757 with :
5858 files : csdmpro.tar.gz
59+
60+ deploy :
61+ name : Deploy csdmpro
62+ needs : build
63+ runs-on : ubuntu-latest
64+
65+ steps :
66+ - name : Checkout code
67+ uses : actions/checkout@v3
68+ with :
69+ path : source
70+
71+ - name : Download artifact
72+ uses : actions/download-artifact@v4
73+ with :
74+ name : csdmpro-release
75+ path : .
76+
77+ - name : Set up SSH key
78+ run : |
79+ mkdir -p ~/.ssh
80+ echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519
81+ chmod 600 ~/.ssh/id_ed25519
82+ ssh-keyscan cs.thekhanj.ir >> ~/.ssh/known_hosts
83+
84+ - name : Deploy using the script
85+ env :
86+ API_TOKEN : ${{ secrets.API_TOKEN }}
87+ TAG : ${{ github.ref_name }}
88+ run : ./source/ci/deploy ./csdmpro.tar.gz
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env sh
2+
3+ if [ -z " $API_TOKEN " ]; then
4+ echo " error: API_TOKEN not provided"
5+ exit 1
6+ fi
7+
8+ file=" $1 "
9+ if ! [ -f " $file " ]; then
10+ echo " error: $file does not exist"
11+ exit 2
12+ fi
13+
14+ scp " $file " root@cs.thekhanj.ir:/tmp || {
15+ echo " error: failed copying file onto remote server"
16+ exit 3
17+ }
18+
19+ ssh root@cs.thekhanj.ir " bash -s" << -EOF
20+ cd /tmp
21+ tar xzvf csdmpro.tar.gz || exit 1
22+ cp csdmpro /usr/bin
23+
24+ cat >/etc/systemd/system/csdmpro.service <<-FART
25+ [Unit]
26+ Description=CSDMPRO Telegram Bot Daemon
27+ After=network.target
28+ Wants=network.target
29+
30+ [Service]
31+ Type=simple
32+ Environment="API_TOKEN=$API_TOKEN "
33+ ExecStart=/usr/bin/csdmpro
34+ Restart=always
35+ RestartSec=2s
36+ User=root
37+ Group=root
38+
39+ [Install]
40+ WantedBy=multi-user.target
41+ FART
42+
43+
44+ systemctl daemon-reload &&
45+ systemctl enable csdmpro &&
46+ systemctl restart csdmpro
47+ EOF
48+
49+ if [ " $? " -ne 0 ]; then
50+ echo ' error: ssh deployment failed'
51+ exit 4
52+ fi
You can’t perform that action at this time.
0 commit comments