Skip to content

Commit

Permalink
Merge pull request #22 from Clever/INFRA-2191-dapple
Browse files Browse the repository at this point in the history
Infra 2191 dapple
  • Loading branch information
nathanleiby authored Mar 1, 2017
2 parents d960efb + 6ac8d6b commit c24e138
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 12 deletions.
42 changes: 31 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -17,23 +21,36 @@ 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.

```
$ ./circleci/npm-publish [NPM_TOKEN] [PACKAGE_DIR]
```

### Github Release
#### Github Release

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).

Expand All @@ -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]
```

59 changes: 59 additions & 0 deletions circleci/dapple-deploy
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion circleci/report-card
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Publishes build and application objects to Catapult.
# Runs report-card to analyze a repo's code health.
#
# Usage:
#
Expand Down

0 comments on commit c24e138

Please sign in to comment.