Skip to content

Commit

Permalink
Deploy built images using rsync.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Jan 23, 2021
1 parent 179c638 commit 63a9b94
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defaults:

jobs:
build:
environment: Deploy
runs-on: ${{matrix.os}}
strategy:
matrix:
Expand All @@ -22,3 +23,9 @@ jobs:
run: sh -ex build/dependencies.sh install_linux
- name: Build
run: make check-dirs all EMULATOR=${{matrix.emulator}}
- name: Deploy
if: github.ref == 'refs/heads/master'
env:
SECRET: ${{secrets.SECRET}}
EMULATOR: ${{matrix.emulator}}
run: sh build/deploy.sh
32 changes: 30 additions & 2 deletions build/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
#!/bin/sh

echo "Here we can do anything when deployment has finished."
echo "Such as kicking off a second build stage."
# At the $HOST, the $USER needs to have an .ssh directory with
# authorized_keys matching $SECRET.

set -e

HOST=hactrn.org
PORT=22
USER=images
DIR=/var/www/hactrn.org/images

SSH=$HOME/.ssh
ID=$SSH/id_rsa

if test -z "$SECRET"; then
echo 'ERROR: No key in $SECRET.'
exit 1
fi

mkdir -p $SSH
chmod 700 $SSH
echo "$SECRET" > $ID
chmod 600 $ID

ssh-keyscan -p $PORT -H $HOST >> ~/.ssh/known_hosts

(cd out; tar czf $EMULATOR.tgz $EMULATOR)

echo "Deploying to $USER@$HOST:$PORT"
rsync -av --inplace -e "ssh -p$PORT -l$USER" out/$EMULATOR.tgz $HOST:$DIR

exit 0

0 comments on commit 63a9b94

Please sign in to comment.