forked from ntv-one/rport
-
Notifications
You must be signed in to change notification settings - Fork 25
66 lines (60 loc) · 2.25 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
59
60
61
62
63
64
65
66
name: Deploy
on:
push:
branches:
- master
jobs:
deploy-to-demo-server:
name: Deploy to demo server
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Build
# set rport version to {date-time}-{github-master-head-sha}
run: go build -v -ldflags="-X 'github.com/realvnc-labs/rport/share.BuildVersion=$(date -u +%y.%m%d.%H%M)-$(git rev-parse HEAD)'" -o ./ ./cmd/...
- name: Build Plus Plugin
shell: bash
env:
RPORT_PLUS_PRIV_KEY: ${{ secrets.RPORT_PLUS_PRIV_KEY }}
run: |
bash .github/scripts/build-plus.sh
- name: Test Build
shell: bash
run: |
bash .github/scripts/start_rportd.sh
bash .github/scripts/start_rport.sh
- name: Copy a new version to remote server
shell: bash
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_PRIV_KEY: ${{ secrets.SSH_PRIV_KEY }}
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
run: |
test -e ~/.ssh || mkdir ~/.ssh
echo "${SSH_PRIV_KEY}" > ~/.ssh/id_ed25519
echo "${SSH_KNOWN_HOSTS}" > ~/.ssh/known_hosts
. ~/.plus.env
chmod 0400 ~/.ssh/*
ls -lah ~/.ssh/
scp -P ${SSH_PORT} rportd ${SSH_USERNAME}@${SSH_HOST}:/tmp/.rportd
echo "✅ Copied rportd to destination"
scp -P ${SSH_PORT} rport-plus/rport-plus.so ${SSH_USERNAME}@${SSH_HOST}:/tmp/rport-plus-${PLUS_LATEST}.so
echo "✅ Copied Rport-Plus to remote host"
ssh -p ${SSH_PORT} ${SSH_USERNAME}@${SSH_HOST} bash << EOF
set -e
sudo -n service rportd stop
# Move rportd to the expected folder
sudo -n mv /tmp/.rportd /usr/local/bin/rportd
# Move the plus plugin to the expected folder
sudo -n mv /tmp/rport-plus-${PLUS_LATEST}.so /usr/local/lib/rport/rport-plus.so
sudo -n service rportd start
/usr/local/bin/rportd --version
EOF
echo "✅ Rportd restarted on remote host"