-
Notifications
You must be signed in to change notification settings - Fork 18
43 lines (41 loc) · 1.21 KB
/
oci.yaml
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
name: Deploy to OCI
on:
workflow_dispatch:
push:
branches: [ "master" ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: SSH Remote Commands
uses: appleboy/[email protected]
env:
NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA: ${{ github.sha }}
with:
# ssh host
host: ${{ secrets.OCI_VM_IP }}
username: ${{ secrets.OCI_VM_USERNAME }}
key: ${{ secrets.OCI_VM_SSH }}
envs: NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
# execute commands
script: |
cd ~/matheditor
echo "Creating a backup of the current build..."
cp -r .next temp
echo "Pulling latest changes..."
git fetch
git reset --hard origin/master
echo "Installing dependencies..."
npm ci -f
npx prisma migrate deploy
echo "Building to temp directory..."
BUILD_DIR=temp npm run build || exit
if [ ! -d "temp" ]; then
echo '\033[31m temp Directory not exists!\033[0m'
exit 1;
fi
echo "Switching live directory..."
rm -rf .next
mv temp .next
pm2 reload matheditor --update-env
echo "Deploy done."