-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (44 loc) · 1.92 KB
/
deploy.yaml
File metadata and controls
54 lines (44 loc) · 1.92 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
name: Deploy discord bot to server
on: [workflow_dispatch]
jobs:
Deploy-Bot-Action:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: executing remote ssh commands using ssh key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.HOST }} >> ~/.ssh/known_hosts
- name: copy files to remote server
run: |
scp -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -r ./* ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/opt/TransactionBot/build
- name: install dependencies
run: |
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF'
cd /opt/TransactionBot/build
npm install
EOF
- name: replace existing directory
run: |
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF'
sudo systemctl stop transactionbot.service
cd /opt/TransactionBot
rm -rf deployed
mv build deployed
mkdir build
EOF
# - todo: separate config files
# - name: copy config files
# run: |
# ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF'
# cd /opt/TransactionBot
# cp -r ./config/* deployed
# EOF
- name: restart systemd process
run: |
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF'
sudo systemctl restart transactionbot.service
EOF