Skip to content

Commit c24e138

Browse files
authored
Merge pull request #22 from Clever/INFRA-2191-dapple
Infra 2191 dapple
2 parents d960efb + 6ac8d6b commit c24e138

File tree

3 files changed

+91
-12
lines changed

3 files changed

+91
-12
lines changed

README.md

+31-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ Owned by `#eng-infra`.
88

99
## Scripts
1010

11-
### Docker
11+
### General-purpose
12+
13+
The following scripts don't rely on any Clever-specific tooling.
14+
15+
#### Docker
1216

1317
Logs into Docker registry, then builds and pushes docker image.
1418
Docker image is tagged with 7 character git commit SHA.
@@ -17,23 +21,36 @@ Docker image is tagged with 7 character git commit SHA.
1721
$ ./circleci/docker-publish [DOCKER_USER] [DOCKER_PASS] [DOCKER_EMAIL] [ORG]
1822
```
1923

20-
### NPM Publish
24+
#### NPM Publish
2125

2226
Authenticates to NPM and publishes a package.
2327

2428
```
2529
$ ./circleci/npm-publish [NPM_TOKEN] [PACKAGE_DIR]
2630
```
2731

28-
### Github Release
32+
#### Github Release
2933

3034
Publishes content from `[ARTIFACTS_DIR]` as a Github Release.
3135

3236
```
3337
$ ./circleci/github-release [GITHUB_TOKEN] [ARTIFACTS_DIR]
3438
```
3539

36-
### Catapult
40+
#### Mongo install
41+
42+
Installs a specific Mongo version, rather than the default version in CircleCI.
43+
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).
44+
45+
```
46+
$ ./circleci/mongo-install [VERSION]
47+
```
48+
49+
### Clever internal
50+
51+
The following scripts depend on Clever-specific infrastructure and tooling.
52+
53+
#### Catapult
3754

3855
Publishes your application and build in [catapult](https://github.com/clever/catapult).
3956

@@ -43,19 +60,22 @@ $ ./circleci/catapult-publish [CATAPULT_URL] [CATAPULT_USER] [CATAPULT_PASS] [AP
4360

4461
If you need to publish multiple applications, run this command once for each.
4562

46-
### Report-card
63+
#### Dapple
4764

48-
Runs [report-card](https://github.com/clever/report-card).
65+
Deploys your application with [dapple](https://github.com/clever/dapple).
66+
Requires that you've first pushed the Docker image and published the application to Catapult.
4967

5068
```
51-
$ ./circleci/report-card [DOCKER_USER] [DOCKER_PASS] [DOCKER_EMAIL] [GITHUB_TOKEN]
69+
$ ./circleci/dapple-deploy [DAPPLE_URL] [DAPPLE_USER] [DAPPLE_PASS] [APP_NAME]
5270
```
5371

54-
### Mongo install
72+
If you need to deploy multiple applications, run this command once for each.
5573

56-
Installs a specific Mongo version, rather than the default version in CircleCI.
57-
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).
74+
#### Report-card
75+
76+
Runs [report-card](https://github.com/clever/report-card).
5877

5978
```
60-
$ ./circleci/mongo-install [VERSION]
79+
$ ./circleci/report-card [DOCKER_USER] [DOCKER_PASS] [DOCKER_EMAIL] [GITHUB_TOKEN]
6180
```
81+

circleci/dapple-deploy

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Submits an application to Dapple deployment pipeline
4+
#
5+
# Usage:
6+
#
7+
# dapple-deploy [DAPPLE_URL] [DAPPLE_USER] [DAPPLE_PASS] [APP_NAME]
8+
#
9+
# Required circleci provided environment variables:
10+
#
11+
# CIRCLE_PROJECT_REPONAME
12+
# CIRCLE_PROJECT_USERNAME
13+
# CIRCLE_BUILD_NUM
14+
#
15+
16+
set -e
17+
18+
if [ $# -ne 4 ]; then
19+
echo "Incorrect number of arguments given. Expected 4, received $#"
20+
echo "Usage: dapple-deploy [DAPPLE_URL] [DAPPLE_USER] [DAPPLE_PASS] [APP_NAME]"
21+
exit 1
22+
fi
23+
24+
# User supplied args
25+
DAPPLE_URL=$1
26+
DAPPLE_USER=$2
27+
DAPPLE_PASS=$3
28+
APP_NAME=$4
29+
30+
# Set automatically by CircleCI
31+
: ${CIRCLE_PROJECT_REPONAME?"Missing required env var"}
32+
REPO=$CIRCLE_PROJECT_REPONAME
33+
: ${CIRCLE_PROJECT_USERNAME?"Missing required env var"}
34+
USER=$CIRCLE_PROJECT_USERNAME
35+
: ${CIRCLE_BUILD_NUM?"Missing required env var"}
36+
BUILD_NUM=$CIRCLE_BUILD_NUM
37+
38+
echo "Publishing to dapple..."
39+
SC=$(curl -u $DAPPLE_USER:$DAPPLE_PASS \
40+
-w "%{http_code}" \
41+
--output dapple.out \
42+
-H "Content-Type: application/json" \
43+
-X POST \
44+
-d "{\"username\":\"$USER\",\"reponame\":\"$REPO\",\"buildnum\":$BUILD_NUM,\"appname\":\"$APP_NAME\"}" \
45+
$DAPPLE_URL)
46+
47+
if [ "$SC" -eq 200 ]; then
48+
echo "Successfully published application to dapple"
49+
rm -f dapple.out
50+
exit 0
51+
else
52+
echo "Failed to publish application to dapple"
53+
echo "------------------------------------------------"
54+
cat dapple.out
55+
echo ""
56+
echo "------------------------------------------------"
57+
rm -f dapple.out
58+
exit 1
59+
fi

circleci/report-card

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Publishes build and application objects to Catapult.
3+
# Runs report-card to analyze a repo's code health.
44
#
55
# Usage:
66
#

0 commit comments

Comments
 (0)