From 7139cf9700e7a343afdbf8d27d6f45b870d12d71 Mon Sep 17 00:00:00 2001 From: Jayasanka Weerasinghe Date: Wed, 15 Jan 2020 13:30:17 +0530 Subject: [PATCH] Configure surge auto-deployment --- .travis.yml | 9 +++++++++ scripts/surge_deploy.sh | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 scripts/surge_deploy.sh diff --git a/.travis.yml b/.travis.yml index e69de29b..088da212 100644 --- a/.travis.yml +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: java +sudo: true +matrix: + include: + # Build the project using maven + - script: + - mvn install + # Deploy PR to surge + - script: bash ./surge_deploy.sh diff --git a/scripts/surge_deploy.sh b/scripts/surge_deploy.sh new file mode 100644 index 00000000..5ae8e96a --- /dev/null +++ b/scripts/surge_deploy.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + echo "Not a PR. Skipping surge deployment" + exit 0 +fi +# Check if the travis credentials exists +if [ -z "$SURGE_LOGIN" ] || [ -z "$SURGE_TOKEN" ]; then + echo "Surge credentials not set. Skipping surge deployment" + exit 0 +fi +# Install surge +npm i -g surge +cd src/main/webapp +# Create a domain to the PR +export DEPLOY_DOMAIN=https://pr-${TRAVIS_PULL_REQUEST}-sef-site.surge.sh +# Upload to surge.sh +surge --project ./build --domain $DEPLOY_DOMAIN;