From 7c59420bee26b534e38395e2da11f84b1e4a1a42 Mon Sep 17 00:00:00 2001 From: Nathan Leiby Date: Wed, 1 Mar 2017 11:14:42 -0800 Subject: [PATCH 1/3] new ci-script: dapple-deploy --- README.md | 11 ++++++++ circleci/dapple-deploy | 59 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100755 circleci/dapple-deploy diff --git a/README.md b/README.md index f830279..1f35323 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,17 @@ $ ./circleci/catapult-publish [CATAPULT_URL] [CATAPULT_USER] [CATAPULT_PASS] [AP If you need to publish multiple applications, run this command once for each. +### Dapple + +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/dapple-deploy [DAPPLE_URL] [DAPPLE_USER] [DAPPLE_PASS] [APP_NAME] +``` + +If you need to deploy multiple applications, run this command once for each. + ### Report-card Runs [report-card](https://github.com/clever/report-card). 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 From bc123dfaad7464c9d1bceba3cd2e0f86aa5453ba Mon Sep 17 00:00:00 2001 From: Nathan Leiby Date: Wed, 1 Mar 2017 11:17:57 -0800 Subject: [PATCH 2/3] report-card: fix typo --- circleci/report-card | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: # From 6ac8d6b70e845e8b00da870b3af2ccbc0ad0d2ba Mon Sep 17 00:00:00 2001 From: Nathan Leiby Date: Wed, 1 Mar 2017 13:34:03 -0800 Subject: [PATCH 3/3] README: separate clever-specific vs general plugins --- README.md | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1f35323..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,7 +60,7 @@ $ ./circleci/catapult-publish [CATAPULT_URL] [CATAPULT_USER] [CATAPULT_PASS] [AP If you need to publish multiple applications, run this command once for each. -### Dapple +#### Dapple 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. @@ -54,7 +71,7 @@ $ ./circleci/dapple-deploy [DAPPLE_URL] [DAPPLE_USER] [DAPPLE_PASS] [APP_NAME] If you need to deploy multiple applications, run this command once for each. -### Report-card +#### Report-card Runs [report-card](https://github.com/clever/report-card). @@ -62,11 +79,3 @@ Runs [report-card](https://github.com/clever/report-card). $ ./circleci/report-card [DOCKER_USER] [DOCKER_PASS] [DOCKER_EMAIL] [GITHUB_TOKEN] ``` -### 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] -```