diff --git a/circleci/breakdown-sync b/circleci/breakdown-sync index 5dd97d8..b7f916a 100755 --- a/circleci/breakdown-sync +++ b/circleci/breakdown-sync @@ -11,7 +11,13 @@ set -e : ${CIRCLE_BRANCH?"Missing required env var"} BRANCH=$CIRCLE_BRANCH -if [[ $BRANCH != "master" ]]; then +: ${CIRCLE_PROJECT_REPONAME?"Missing required env var"} +REPO=$CIRCLE_PROJECT_REPONAME +: ${GITHUB_TOKEN?"Missing required env var"} +DEFAULT_BRANCH=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/Clever/$REPO" | jq -r '.default_branch') + +if [[ $BRANCH != $DEFAULT_BRANCH ]]; then echo "Skipping sync for non-master branch" exit 0 fi diff --git a/circleci/catalog-sync b/circleci/catalog-sync index 0f5aa56..826e3c4 100755 --- a/circleci/catalog-sync +++ b/circleci/catalog-sync @@ -12,7 +12,12 @@ set -e : ${CIRCLE_BRANCH?"Missing required env var"} BRANCH=$CIRCLE_BRANCH -if [[ $BRANCH != "master" ]]; then +: ${CIRCLE_PROJECT_REPONAME?"Missing required env var"} +REPO=$CIRCLE_PROJECT_REPONAME +: ${GITHUB_TOKEN?"Missing required env var"} +DEFAULT_BRANCH=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/Clever/$REPO" | jq -r '.default_branch') +if [[ $BRANCH != $DEFAULT_BRANCH ]]; then echo "Skipping sync for non-master branch" exit 0 fi diff --git a/circleci/output-force-deploy b/circleci/output-force-deploy index a90778d..7de05f5 100755 --- a/circleci/output-force-deploy +++ b/circleci/output-force-deploy @@ -5,7 +5,9 @@ REPO=$CIRCLE_PROJECT_REPONAME : ${CIRCLE_PROJECT_USERNAME?"Missing required env var"} USER=$CIRCLE_PROJECT_USERNAME - +: ${GITHUB_TOKEN?"Missing required env var"} +DEFAULT_BRANCH=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/Clever/$REPO" | jq -r '.default_branch') echo "frontend-test failed! As a result, your deploy will not start automatically." echo "If you think this is a transient issue, try re-running this job with the \"Rerun from failed\" option." echo "To force deploy, do the following:" @@ -14,7 +16,7 @@ echo "2) Run the following command, replacing CIRCLE_API_TOKEN with the token fr echo "curl -u CIRCLE_API_TOKEN: \\ -X POST \\ --header \"Content-Type: application/json\" -d '{ - \"branch\": \"master\", + \"branch\": \"${DEFAULT_BRANCH}\", \"parameters\": { \"force_deploy\": true }