add auto-update script

This commit is contained in:
Jörg Thalheim 2018-06-29 12:45:20 +01:00
parent 351bfefbc3
commit 2210822b27
3 changed files with 38 additions and 5 deletions

View file

@ -1,7 +1,9 @@
sudo: required
os:
- osx
- linux
language: nix
before_install:
- openssl aes-256-cbc -K $encrypted_025d6e877aa4_key -iv $encrypted_025d6e877aa4_iv -in ci/deploy_key.enc -out deploy_key -d
- chmod 600 deploy_key
- eval "$(ssh-agent -s)"
- ssh-add deploy_key
- rm deploy_key
script:
- nix-build
- bash ci/deploy.sh

31
ci/deploy.sh Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -eux -o pipefail # Exit with nonzero exit code if anything fails
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]] || \
[[ "$TRAVIS_BRANCH" != master ]] && \
[[ "$TRAVIS_BRANCH" != "$(cat .version)" ]]; then
echo "Skipping deploy; just doing a build."
python ./bin/update.py
nix-build
exit 0
fi
python ./bin/update.py
nix-build
if [ "$TRAVIS_BRANCH" = master ]; then
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"
if [ -z "$(git diff --exit-code)" ]; then
echo "No changes to the output on this push; exiting."
exit 0
fi
git add --all repos.json*
git commit -m "automatic update"
git push origin master
fi

BIN
ci/deploy_key.enc Normal file

Binary file not shown.