-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (37 loc) · 1.21 KB
/
deploy.yml
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
name: Deploy
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
name: "Deploy"
runs-on: ubuntu-latest
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy-key.pem
chmod 600 ~/.ssh/deploy-key.pem
cat >> ~/.ssh/config <<END
Host my-vps
HostName $SSH_IP
User $SSH_USER
IdentityFile ~/.ssh/deploy-key.pem
StrictHostKeyChecking no
Port $SSH_PORT
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_IP: ${{ secrets.SSH_IP }}
SSH_PORT: ${{ secrets.SSH_PORT }}
- name: Run deployment script on project root directory
run: ssh my-vps 'cd ${{ secrets.PROJECT_ROOT }} && git fetch && git pull && ./prod.sh'
- name: Notify Discord of Success
if: success()
run: curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=🚀 Deployment Successful"
- name: Notify Discord of Failure
if: failure()
run: curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=❌ Deployment Failed"