Commit e5caec70 authored by Rémy Coutable's avatar Rémy Coutable 🏖

Add .gitlab-ci.yml

Signed-off-by: Rémy Coutable's avatarRémy Coutable <remy@rymai.me>
parent f4f7fb0a
# This file is a template, and might need editing before it works on your project.
# This template uses the non default language docker image
# The image already has Hex installed. You might want to consider to use `elixir:latest`
image: trenpixster/elixir:latest
.before_script_deploy: &before_script_deploy
before_script:
- >
: "${HEROKU_EMAIL:?Please set HEROKU_EMAIL in your CI/CD config vars}"
- >
: "${HEROKU_AUTH_TOKEN:?Please set HEROKU_AUTH_TOKEN in your CI/CD config vars}"
- curl https://cli-assets.heroku.com/install-standalone.sh | sh
- |
cat >~/.netrc <<EOF
machine api.heroku.com
login $HEROKU_EMAIL
password $HEROKU_AUTH_TOKEN
machine git.heroku.com
login $HEROKU_EMAIL
password $HEROKU_AUTH_TOKEN
EOF
- chmod 600 ~/.netrc
- git config --global user.email "remy@rymai.me"
- git config --global user.name "Rémy Coutable"
test:
stage: test
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service
services:
- postgres:latest
before_script:
- mix deps.get
script:
- mix test
variables:
APPNAME_PRODUCTION: i-love
APPNAME_STAGING: i-love-staging
deploy_to_staging:
<<: *before_script_deploy
stage: deploy
environment:
name: staging
url: https://$APPNAME_STAGING.herokuapp.com/
script:
- git remote add staging https://git.heroku.com/$APPNAME_STAGING.git
- git push staging master
- heroku pg:backups:capture --app $APPNAME_PRODUCTION
- heroku pg:backups:restore `heroku pg:backups:url --app $APPNAME_PRODUCTION` --app $APPNAME_STAGING --confirm $APPNAME_STAGING
- heroku run mix exto.migrate --app $APPNAME_STAGING
when: manual
only:
- master
deploy_to_production:
stage: deploy
environment:
name: production
url: https://$APPNAME_PRODUCTION.herokuapp.com/
script:
- git remote add production https://git.heroku.com/$APPNAME_PRODUCTION.git
- git push production master
- heroku pg:backups:capture --app $APPNAME_PRODUCTION
- heroku run mix exto.migrate --app $APPNAME_PRODUCTION
when: manual
only:
- master
......@@ -15,5 +15,5 @@ config :i_love_api, ILoveApi.Repo,
username: "postgres",
password: "postgres",
database: "i_love_api_test",
hostname: "localhost",
hostname: if(System.get_env("CI"), do: "postgres", else: "localhost"),
pool: Ecto.Adapters.SQL.Sandbox
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment