How do I setup auto-deploy from GitLab repo to Meteor Galaxy?


#1

Hello, the idea here is to every time a specific branch of my repository (GitLab) is updated it should make a new deploy to the Meteor Galaxy. Has anyone done it? Do you know a tutorial for this?


#2

We don’t use GitLab, but it looks like GitLab CI/CD is similar to Bitbucket Pipelines, which we do use to deploy to Galaxy on commits to both our staging and production git branches.

It looks like from the quickstart guide that you just need to create a YAML file in your git repo root and configure your project to use Runner. Probably want to make sure to use an OS image with Node 8 installed. Your YAML file will at a minimum need to include some Meteor specific commands to install Meteor and then call the meteor deploy command.

Also, you will need to generate a Meteor login session token (expires I think after 90 days) and copy it into a GitLab environment variable named something like DEPLOY_SESSION_FILE. To generate the token you need to be able to login in to Meteor as your Galaxy user before executing this command from your local development console:

$ METEOR_SESSION_FILE=deployment_token.json meteor login

I can’t give you an exact working script as I have no way to test it. However this should give you a general idea of what you need to put in your YAML file to deploy a staging branch and you can figure out the exact required syntax. Report back when you get a working script.

image: node:8

before_script:
  - curl https://install.meteor.com/ | sh
  - meteor npm install

deployStaging:
  script:
    - echo $DEPLOY_SESSION_FILE > deployment_token.json
    - METEOR_SESSION_FILE=deployment_token.json DEPLOY_HOSTNAME=galaxy.meteor.com meteor deploy --allow-superuser myApp-staging.meteorapp.com --settings config/staging/settings.json --owner username

  only:
    - staging
  tags:
    - docker