Last active
August 21, 2017 01:49
-
-
Save upvalue/ec27cb7b835cd76559b64f7ad639cc4e to your computer and use it in GitHub Desktop.
Try a new CircleCI config without committing
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
#!/usr/bin/env bash | |
# circleci-try.sh -- Tries to run a new .circleci/config.yml from a checked out github repo without committing | |
# Usage: circleci-try.sh from the toplevel of a Git repo | |
# Requires $CIRCLECI_CLI_TOKEN to be set | |
# Thanks: https://discuss.circleci.com/t/running-new-config-files-without-committing/11842 | |
set -x | |
GITHUB_REPO_STR=`git config --get remote.origin.url` | |
RESULT=$? | |
if [ $RESULT -eq 0 ]; then | |
echo $GITHUB_REPO_STR | |
if [[ $GITHUB_REPO_STR =~ [email protected]:([-0-9a-zA-Z\/]+) ]]; then | |
#echo ${BASH_REMATCH[1]} | |
curl --user ${CIRCLECI_CLI_TOKEN}: \ | |
--request POST \ | |
--form [email protected]/config.yml \ | |
--form notify=false \ | |
https://circleci.com/api/v1.1/project/github/${BASH_REMATCH[1]}/tree/master | |
else | |
echo ${BASH_REMATCH} | |
echo "circleci-try.sh: Failed to match github repo. Are you sure you're in a repo checked out from GitHub?" | |
fi | |
else | |
echo "circleci-try.sh: git config --get remote.origin.url failed. Are you sure you're in a git repository?" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment