Skip to content

Instantly share code, notes, and snippets.

@Pushplaybang
Last active February 2, 2019 20:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pushplaybang/1757f48d134924bfd52ab3001ffb0df0 to your computer and use it in GitHub Desktop.
Save Pushplaybang/1757f48d134924bfd52ab3001ffb0df0 to your computer and use it in GitHub Desktop.
Circle CI configuration for building, linting, testing and deploying a meteor application to galaxy.

How To CI meteor

create a circle.yml file in your root directory, using the above as a template.

By default this assumes:

  • you have development tools assetsand config in your root project directory
  • you have your meteor app in the /app directory.
  • you're using grunt from your root directory, this could be any task runner
  • you've setup a test command using your package.json (circle automatically runs this, you could also create overrides)

You'll require a deployment token run this on the command line

METEOR_SESSION_FILE=deployment_token.json meteor login

You'll then need to add three environmental variables to your project on circle CI,

  • DEPLOYMENT_TOKEN - copy the content of the file you created above as the value.
  • STAGE_SETTINGS - copy the contents of your settings file for your staging environment as the value
  • PROD_SETTINGS - copy the contents of your settings file for your production environment as the value

You should be all set.

for linting I've got the following in my package.json:

"devDependencies": {
    "babel-eslint": "^7.1.1",
    "eslint": "^3.15.0",
    "eslint-config-airbnb": "^14.1.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^4.0.0",
    "eslint-plugin-react": "^6.10.0",
    "eslint-plugin-standard": "^2.0.1"
  }

I use the pretest script hook in the package.json to run the linting before any tests.

  "scripts": {
    "pretest": "npm run lint",
    "test": "echo 'tests coming soon!'",
    "lint": "./node_modules/.bin/eslint ./app",
  },
# use the default node box and isntall meteor
machine:
node:
version: 4.2.6
pre:
# download if meteor isn't already installed in the cache
- meteor || curl https://install.meteor.com | /bin/sh
post:
- meteor --version
# install dev and meteor npm dependancies
dependencies:
cache_directories:
- app/.meteor
override:
- npm install -g grunt-cli
- npm install
- cd app/ && npm install
# Automatically deploy to staging and production
deployment:
staging:
branch: "development"
commands:
- grunt
- cd app/ && echo $STAGE_SETTINGS > settings-staging.json
- cd app/ && echo $DEPLOYMENT_TOKEN > deployment_token.json
- cd app/ && METEOR_SESSION_FILE=deployment_token.json DEPLOY_HOSTNAME=eu-west-1.galaxy-deploy.meteor.com meteor deploy staging.<YOUR_DOMAIN>.com --settings settings-staging.json
production:
branch: "master"
commands:
- grunt
- cd app/ && echo $PROD_SETTINGS > settings-production.json
- cd app/ && echo $DEPLOYMENT_TOKEN > deployment_token.json
- cd app/ && METEOR_SESSION_FILE=deployment_token.json DEPLOY_HOSTNAME=eu-west-1.galaxy-deploy.meteor.com meteor deploy www.<YOUR_DOMAIN>.com --settings settings-production.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment