-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (70 loc) · 2.14 KB
/
rollback_SHA.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Rollback project
on:
workflow_dispatch:
inputs:
commit:
description: 'Enter commit SHA to rollback to.'
required: true
type: string
additional_command:
description: 'Do you have any additional command to apply? ex) ./manage.py update_translation_fields'
required: false
type: string
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy Backend Code
uses: appleboy/ssh-action@v0.1.4
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_KEY }}
script: |
source ~/venv3.9/bin/activate
cd /home/ubuntu/adoor
git checkout main ${{ github.event.inputs.commit }}
git pull
cd /home/ubuntu/adoor/backend/adoorback
pip install -r requirements.txt
./manage.py migrate
${{ github.event.inputs.additional_command }}
sudo systemctl restart uwsgi
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit }}
- name: Set up Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build frontend
run: |
cd frontend
yarn install
CI='false' yarn run build --prod
- name: Remove previous build file
uses: appleboy/ssh-action@v0.1.4
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_KEY }}
script: |
cd /home/ubuntu/adoor/frontend
rm -r build
- name: scp artifacts to server
uses: appleboy/scp-action@v0.1.3
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_KEY }}
source: "frontend/build"
target: "~/adoor"
- name: Restart Nginx service
uses: appleboy/ssh-action@v0.1.4
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_KEY }}
script: |
sudo systemctl restart nginx.service