summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Enders <senders@spotify.com>2019-01-21 14:24:39 -0500
committerStephen Enders <senders@spotify.com>2019-01-21 14:24:39 -0500
commitb8e61ad5c17082cfce6fd2945037f6df691d2627 (patch)
tree98700887639f180f2f5c5e26ed46a73a5783d867
parentf8bc07f42f3866d32c777c0f3b6300fd99a4e2e2 (diff)
Deploy test
-rw-r--r--.gitignore2
-rwxr-xr-xdeploy.sh51
2 files changed, 53 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..232b89f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+www/version.info
+*.sw*
diff --git a/deploy.sh b/deploy.sh
new file mode 100755
index 0000000..3b07862
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+set -e
+
+# Stolen from: https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes
+require_clean_work_tree () {
+ # Update the index
+ git update-index -q --ignore-submodules --refresh
+ err=0
+
+ # Disallow unstaged changes in the working tree
+ if ! git diff-files --quiet --ignore-submodules --
+ then
+ echo >&2 "cannot $1: you have unstaged changes."
+ git diff-files --name-status -r --ignore-submodules -- >&2
+ err=1
+ fi
+
+ # Disallow uncommitted changes in the index
+ if ! git diff-index --cached --quiet HEAD --ignore-submodules --
+ then
+ echo >&2 "cannot $1: your index contains uncommitted changes."
+ git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
+ err=1
+ fi
+
+ if [ $err = 1 ]
+ then
+ echo >&2 "Please commit or stash them."
+ exit 1
+ fi
+}
+
+## ##
+# MAIN METHOD #
+## ##
+DATE=$(date -u -Iseconds)
+
+echo "Checking git for clean work tree"
+require_clean_work_tree
+
+echo "Updating version file"
+echo "Deployed on: $DATE" > www/version.info
+
+#aws s3 cp www s3://senders-io/ --recursive
+echo "Deployed!"
+
+echo "Committing deploy"
+git commit -am "Deployed: $DATE"
+git tag -a $DATE -m "Deployed to s3 on $DATE"
+echo "Done!"
+