-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (57 loc) · 1.93 KB
/
deploy.yml
File metadata and controls
69 lines (57 loc) · 1.93 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
name: Build, Test and Deploy Discord Bot to VPS
on:
workflow_dispatch: # Manual trigger only
# Uncomment below when VPS is ready:
# push:
# branches: [ "main" ]
# paths-ignore:
# - 'docs/**'
# - '.gitignore'
# - 'LICENSE'
jobs:
build-test-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Build bot
run: npm run build:ci
- name: Run tests
run: npm test:ci
- name: Package build output
run: tar czf bot-build.tar.gz ./dist
- name: Copy build artifact to VPS
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
source: "bot-build.tar.gz"
target: "/home/${{ secrets.VPS_USER }}/discord-bot/"
- name: Create .env file on VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
echo "DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}" > /home/${{ secrets.VPS_USER }}/discord-bot/.env
echo "CLIENT_ID=${{ secrets.CLIENT_ID }}" >> /home/${{ secrets.VPS_USER }}/discord-bot/.env
- name: Extract and restart bot on VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
cd /home/${{ secrets.VPS_USER }}/discord-bot/
tar xzf bot-build.tar.gz
pm2 restart bot || pm2 start ./dist/index.js --name bot