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 22, 2021
1 parent 179c638 commit 1265bfe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
6 changes: 6 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,8 @@ 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}}
run: sh build/deploy.sh
30 changes: 28 additions & 2 deletions build/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
#!/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

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

exit 0

0 comments on commit 1265bfe

Please sign in to comment.