Skip to content

Instantly share code, notes, and snippets.

@nagelflorian
Created January 14, 2016 13:04
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nagelflorian/2e7509750d1254a1549a to your computer and use it in GitHub Desktop.
Save nagelflorian/2e7509750d1254a1549a to your computer and use it in GitHub Desktop.
CircleCI File for Meteor using Velocity with Jasmine and Galaxy for deployment
machine:
node:
version: 0.10.40
pre:
# download if meteor isn't already installed in the cache
- meteor || curl https://install.meteor.com | /bin/sh
post:
- meteor --version
checkout:
post:
- git submodule sync
- git submodule update --init --recursive
dependencies:
override:
- npm install -g velocity-cli
test:
override:
- echo $METEOR_SETTINGS > settings.json
- rm -rf tests/jasmine/client
- velocity test-app --ci --settings settings.json
deployment:
staging:
branch: "production"
commands:
- meteor add meteorhacks:kadira
- echo $METEOR_TOKEN > deployment_token.json
- echo METEOR_SETTINGS_STAGING > settings.json
# The content of the METEOR_SESSION_FILE is generated with:
# 'METEOR_SESSION_FILE=deployment_token.json meteor login'
- DEPLOY_HOSTNAME=galaxy.meteor.com METEOR_SESSION_FILE=deployment_token.json meteor deploy $METEOR_TARGET --settings settings.json
@nagelflorian
Copy link
Author

You need to add the following Environment variables to your CircleCI project settings:

  • METEOR_SETTINGS
  • METEOR_SETTINGS_STAGING
  • METEOR_TOKEN (Meteor session token to login to your account)
  • METEOR_TARGET (Your deployment url, e.g. www.example.com)

@gregorynicholas
Copy link

how did you generate the deployment_token.json file ? what does that file look like (or supposed to look like)?

@TimFletcher
Copy link

@samhatoum
Copy link

Thanks for posting this, I found it useful and have extended it a little.

FWIW, I prefer to encode the string to Base64 first. While Circle supports multi-line environment variables, some CI servers don't so here's how you do it when that's the case.

Start by getting the session file as above:

METEOR_SESSION_FILE=meteor-session-file.json meteor login

Then load the file into an environment variable and use node.js to convert the file content to a BASE64 string:

FILE_CONTENT=`cat meteor-session-file.json` node -e "console.log(new Buffer(process.env.FILE_CONTENT).toString('base64'))"

Copy and paste the BASE64 string into an environment variable field called METEOR_SESSION_FILE_CONTENT in your CI server.

Then when you're creating the file, you can use this:

deployment:
  ...
  - node -e "console.log(new Buffer(process.env.METEOR_SESSION_FILE, 'base64').toString('utf-8'))" > deployment_token.json
  ...
  - DEPLOY_HOSTNAME=galaxy.meteor.com METEOR_SESSION_FILE=deployment_token.json meteor deploy $METEOR_TARGET

Hope that helps someone

@levithomason
Copy link

@samhatoum since JSON doesn't require whitespace you could simply remove it:

{
  "valid": true,
  "foo": "bar"
}

Becomes:

{"valid":true,"foo":"bar"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment