-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (50 loc) · 1.65 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
51
52
53
54
55
56
57
58
name: Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Docker image
run: docker build -t trackme-builder .
- name: Extract binary from Docker container
run: |
docker create --name extract trackme-builder
docker cp extract:/app/trackme ./trackme
docker rm extract
- name: Copy assets and templates
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
source: "trackme,web"
target: "~/track-me-temp/"
- name: Deploy to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
~/track-me-temp/trackme --ping
if [ $? -eq 0 ]; then
echo "New binary test passed. Proceeding with deployment."
sudo systemctl stop trackme.service
mv ~/track-me-temp/trackme /root/track-me/trackme
rsync -av ~/track-me-temp/web/assets/* /root/track-me/web/assets
rsync -av ~/track-me-temp/web/templates/* /root/track-me/web/templates
sudo systemctl start trackme.service
else
echo "New binary test failed. Aborting deployment."
exit 1
fi
rm -rf ~/track-me-temp/*