This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy-via-cron.sh
executable file
·64 lines (48 loc) · 1.6 KB
/
deploy-via-cron.sh
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
#! /bin/bash
#
# A little script that runs a basic test before pushing the build artifact to Vagrant Cloud.
#
# Exit script if we detect an error
set -eE
PROJECT_DIR="$(dirname ${BASH_SOURCE[0]})"
# Cleanup after errors before we exit
cleanup() {
echo "Cleaning up after error..."
if [[ "$PWD" == "*/vagrant/hyrax" ]]; then
vagrant destroy -f
fi
}
# Try to cleanup before exiting if we detect an error
trap cleanup ERR
# Make sure we're running from the right directory
cd "${PROJECT_DIR}"
# Confirm that jq is installed on the system
hash jq 2>/dev/null || {
echo >&2 "jq must be installed to run this script: https://stedolan.github.io/jq/download/"
exit 1
}
# Set variables from our project config file
PROJECT_OWNER=$(jq --raw-output '.project_owner' config.json)
PROJECT_NAME=$(jq --raw-output '.project_name' config.json)
# Build the base box
./build.sh base box
# Install the Hyrax application into the base box
./build.sh hyrax box
# Change into our Vagrant directory and bring up box
cd "vagrant/hyrax"
set +eE
vagrant box remove -f "${PROJECT_OWNER}/${PROJECT_NAME}" 2>&1 >/dev/null
set -eE
vagrant box add "${PROJECT_OWNER}/${PROJECT_NAME}" "../../builds/vagrant/${PROJECT_NAME}.box"
vagrant up
# Run some simple sanity checks
curl -sSf "http://localhost:8080" > /dev/null
curl -sSf "http://localhost:8984/fedora/rest" > /dev/null
curl -sSf "http://localhost:8983" > /dev/null
# Run some more sophisticated checks inside the VM
vagrant ssh -c "cd ${PROJECT_NAME}; bundle exec rake ci"
# Clean up the box
vagrant destroy -f
# Finally, do a real deploy to Vagrant Cloud
cd ../..
./deploy.sh hyrax box