Skip to content

Commit 1265bfe

Browse files
committed
Deploy built images using rsync.
1 parent 179c638 commit 1265bfe

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ defaults:
88

99
jobs:
1010
build:
11+
environment: Deploy
1112
runs-on: ${{matrix.os}}
1213
strategy:
1314
matrix:
@@ -22,3 +23,8 @@ jobs:
2223
run: sh -ex build/dependencies.sh install_linux
2324
- name: Build
2425
run: make check-dirs all EMULATOR=${{matrix.emulator}}
26+
- name: Deploy
27+
if: github.ref == 'refs/heads/master'
28+
env:
29+
SECRET: ${{secrets.SECRET}}
30+
run: sh build/deploy.sh

build/deploy.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
#!/bin/sh
22

3-
echo "Here we can do anything when deployment has finished."
4-
echo "Such as kicking off a second build stage."
3+
# At the $HOST, the $USER needs to have an .ssh directory with
4+
# authorized_keys matching $SECRET.
5+
6+
set -e
7+
8+
HOST=hactrn.org
9+
PORT=22
10+
USER=images
11+
DIR=/var/www/hactrn.org/images
12+
13+
SSH=$HOME/.ssh
14+
ID=$SSH/id_rsa
15+
16+
if test -z "$SECRET"; then
17+
echo 'ERROR: No key in $SECRET.'
18+
exit 1
19+
fi
20+
21+
mkdir -p $SSH
22+
chmod 700 $SSH
23+
echo "$SECRET" > $ID
24+
chmod 600 $ID
25+
26+
ssh-keyscan -p $PORT -H $HOST >> ~/.ssh/known_hosts
27+
28+
echo "Deploying to $USER@$HOST:$PORT"
29+
rsync -av --inplace -e "ssh -p$PORT -l$USER" out $HOST:$DIR
30+
531
exit 0

0 commit comments

Comments
 (0)