-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5f939a
commit b8e8cd2
Showing
4 changed files
with
364 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# Split on "/", ref: http://stackoverflow.com/a/5257398/689223 | ||
REPO_SLUG_ARRAY=(${TRAVIS_REPO_SLUG//\// }) | ||
REPO_OWNER=${REPO_SLUG_ARRAY[0]} | ||
REPO_NAME=${REPO_SLUG_ARRAY[1]} | ||
DEPLOY_PATH=./public | ||
|
||
|
||
if [ "$TRAVIS_PULL_REQUEST" != "false" ] | ||
then | ||
DEPLOY_SUBDOMAIN_UNFORMATTED_LIST=(${TRAVIS_PULL_REQUEST}-pr) | ||
for DEPLOY_SUBDOMAIN_UNFORMATTED in "${DEPLOY_SUBDOMAIN_UNFORMATTED_LIST[@]}" | ||
do | ||
echo $DEPLOY_SUBDOMAIN_UNFORMATTED | ||
# replaces "/" or "." with "-" | ||
# sed -r is only supported in linux, ref http://stackoverflow.com/a/2871217/689223 | ||
# Domain names follow the RFC1123 spec [a-Z] [0-9] [-] | ||
# The length is limited to 253 characters | ||
# https://en.wikipedia.org/wiki/Domain_Name_System#Domain_name_syntax | ||
DEPLOY_SUBDOMAIN=`echo "$DEPLOY_SUBDOMAIN_UNFORMATTED" | sed -r 's/[\/|\.]+/\-/g'` | ||
DEPLOY_DOMAIN=https://${DEPLOY_SUBDOMAIN}-${REPO_NAME}-${REPO_OWNER}.surge.sh | ||
surge --project ${DEPLOY_PATH} --domain $DEPLOY_DOMAIN; | ||
# Using the Issues api instead of the PR api | ||
# Done so because every PR is an issue, and the issues api allows to post general comments, | ||
# while the PR api requires that comments are made to specific files and specific commits | ||
GITHUB_PR_COMMENTS=https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments | ||
curl -H "Authorization: token ${GITHUB_API_TOKEN}" --request POST ${GITHUB_PR_COMMENTS} --data '{"body":"Review change(s): '${DEPLOY_DOMAIN}'"}' | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.