-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (45 loc) · 1.31 KB
/
deploy-preview.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
44
45
name: Deploy Preview
on:
push:
branches:
- 'main'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to Preview Server
uses: appleboy/[email protected]
env:
MICONFIG: ${{ secrets.MICONFIG_PREVIEW }}
PK: ${{ secrets.BENTO_PK_PREVIEW }}
with:
host: ${{ secrets.PREVIEW_SERVER_IP }}
username: ${{ secrets.PREVIEW_USER }}
key: ${{ secrets.PREVIEW_SERVER_SSH_KEY }}
envs: MICONFIG,PK
script: |
clean_up() {
echo "Performing cleanup..."
cd ~
echo "Remove repository"
rm -rf repo
echo "Docker cleanup"
docker system prune -f
echo "Done: Cleanup"
}
handle_error() {
clean_up
echo "Failed to deploy preview"
exit 1
}
trap 'handler_error' ERR
echo "Cloning repository"
cd ~
rm -rf repo
git clone [email protected]:${{ github.repository }}.git repo
cd repo
echo "Copy deploy preview script"
cp .github/scripts/deploy-preview.sh .
echo "Running deploy-preview.sh"
chmod +x deploy-preview.sh
./deploy-preview.sh