diff --git a/README.md b/README.md index f830279..4a89ce6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,11 @@ Owned by `#eng-infra`. ## Scripts -### Docker +### General-purpose + +The following scripts don't rely on any Clever-specific tooling. + +#### Docker Logs into Docker registry, then builds and pushes docker image. Docker image is tagged with 7 character git commit SHA. @@ -17,7 +21,7 @@ Docker image is tagged with 7 character git commit SHA. $ ./circleci/docker-publish [DOCKER_USER] [DOCKER_PASS] [DOCKER_EMAIL] [ORG] ``` -### NPM Publish +#### NPM Publish Authenticates to NPM and publishes a package. @@ -25,7 +29,7 @@ Authenticates to NPM and publishes a package. $ ./circleci/npm-publish [NPM_TOKEN] [PACKAGE_DIR] ``` -### Github Release +#### Github Release Publishes content from `[ARTIFACTS_DIR]` as a Github Release. @@ -33,7 +37,20 @@ Publishes content from `[ARTIFACTS_DIR]` as a Github Release. $ ./circleci/github-release [GITHUB_TOKEN] [ARTIFACTS_DIR] ``` -### Catapult +#### Mongo install + +Installs a specific Mongo version, rather than the default version in CircleCI. +At time of writing, `v3.0.7` was default version in CircleCI's [Ubuntu 14.04 (Trusty) image](https://circleci.com/docs/build-image-trusty/#mongodb). + +``` +$ ./circleci/mongo-install [VERSION] +``` + +### Clever internal + +The following scripts depend on Clever-specific infrastructure and tooling. + +#### Catapult Publishes your application and build in [catapult](https://github.com/clever/catapult). @@ -43,19 +60,22 @@ $ ./circleci/catapult-publish [CATAPULT_URL] [CATAPULT_USER] [CATAPULT_PASS] [AP If you need to publish multiple applications, run this command once for each. -### Report-card +#### Dapple -Runs [report-card](https://github.com/clever/report-card). +Deploys your application with [dapple](https://github.com/clever/dapple). +Requires that you've first pushed the Docker image and published the application to Catapult. ``` -$ ./circleci/report-card [DOCKER_USER] [DOCKER_PASS] [DOCKER_EMAIL] [GITHUB_TOKEN] +$ ./circleci/dapple-deploy [DAPPLE_URL] [DAPPLE_USER] [DAPPLE_PASS] [APP_NAME] ``` -### Mongo install +If you need to deploy multiple applications, run this command once for each. -Installs a specific Mongo version, rather than the default version in CircleCI. -At time of writing, `v3.0.7` was default version in CircleCI's [Ubuntu 14.04 (Trusty) image](https://circleci.com/docs/build-image-trusty/#mongodb). +#### Report-card + +Runs [report-card](https://github.com/clever/report-card). ``` -$ ./circleci/mongo-install [VERSION] +$ ./circleci/report-card [DOCKER_USER] [DOCKER_PASS] [DOCKER_EMAIL] [GITHUB_TOKEN] ``` + diff --git a/circleci/dapple-deploy b/circleci/dapple-deploy new file mode 100755 index 0000000..b71026e --- /dev/null +++ b/circleci/dapple-deploy @@ -0,0 +1,59 @@ +#!/bin/bash + +# Submits an application to Dapple deployment pipeline +# +# Usage: +# +# dapple-deploy [DAPPLE_URL] [DAPPLE_USER] [DAPPLE_PASS] [APP_NAME] +# +# Required circleci provided environment variables: +# +# CIRCLE_PROJECT_REPONAME +# CIRCLE_PROJECT_USERNAME +# CIRCLE_BUILD_NUM +# + +set -e + +if [ $# -ne 4 ]; then + echo "Incorrect number of arguments given. Expected 4, received $#" + echo "Usage: dapple-deploy [DAPPLE_URL] [DAPPLE_USER] [DAPPLE_PASS] [APP_NAME]" + exit 1 +fi + +# User supplied args +DAPPLE_URL=$1 +DAPPLE_USER=$2 +DAPPLE_PASS=$3 +APP_NAME=$4 + +# Set automatically by CircleCI +: ${CIRCLE_PROJECT_REPONAME?"Missing required env var"} +REPO=$CIRCLE_PROJECT_REPONAME +: ${CIRCLE_PROJECT_USERNAME?"Missing required env var"} +USER=$CIRCLE_PROJECT_USERNAME +: ${CIRCLE_BUILD_NUM?"Missing required env var"} +BUILD_NUM=$CIRCLE_BUILD_NUM + +echo "Publishing to dapple..." +SC=$(curl -u $DAPPLE_USER:$DAPPLE_PASS \ + -w "%{http_code}" \ + --output dapple.out \ + -H "Content-Type: application/json" \ + -X POST \ + -d "{\"username\":\"$USER\",\"reponame\":\"$REPO\",\"buildnum\":$BUILD_NUM,\"appname\":\"$APP_NAME\"}" \ + $DAPPLE_URL) + +if [ "$SC" -eq 200 ]; then + echo "Successfully published application to dapple" + rm -f dapple.out + exit 0 +else + echo "Failed to publish application to dapple" + echo "------------------------------------------------" + cat dapple.out + echo "" + echo "------------------------------------------------" + rm -f dapple.out + exit 1 +fi diff --git a/circleci/report-card b/circleci/report-card index e2ff08a..be5e7a8 100755 --- a/circleci/report-card +++ b/circleci/report-card @@ -1,6 +1,6 @@ #!/bin/bash -# Publishes build and application objects to Catapult. +# Runs report-card to analyze a repo's code health. # # Usage: #