generated from MLH-Fellowship/pe-portfolio-site
-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (44 loc) · 1.63 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
43
44
45
46
47
48
49
50
name: Deploy
on:
workflow_run:
workflows: ["Run Tests"]
branch:
- main
types:
- completed
jobs:
deploy:
name: "Deploy to VPS"
runs-on: ubuntu-latest
if: ${{ github.event.inputs.tests_failed == 'false' }}
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
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_IP: ${{ secrets.SSH_IP }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy site
run: ssh my-vps '~/redeploy-site.sh'
- name: Send Discord Notification
run: curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=🚀 Deployment Successful"
- name: Print Container Status
run: ssh my-vps 'docker ps'
failure-notification:
name: "Notify Failure"
runs-on: ubuntu-latest
needs: deploy
if: ${{ needs.deploy.result == 'failure' || github.event.inputs.tests_failed == 'true' }}
steps:
- name: Send Discord Notification on Failure
run: curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=🚨 Deployment Failed"