Reputation: 27
I have successfully deployed a showoff presentation on Heroku. Because Heroku makes it so easy to integrate Github, I have also been able to add a Github repository that auto-deploys on Heroku.
I want to setup the same thing in Gitlab. Can someone please help me in setting it up?
The app.json
used by Github is as follows:
{
"name": "lunar-teach",
"scripts": {
},
"env": {
"LANG": {
"required": true
},
"RACK_ENV": {
"required": true
}
},
"formation": {
},
"addons": [
],
"buildpacks": [
{
"url": "heroku/ruby"
}
]
}
Upvotes: 0
Views: 735
Reputation: 27
Use the following .gitlab-ci.yml
config:
For this config to work, you need to get your heroku API key.
First define the stages you want to use, If you want to add testing to your CI pipeline, add it here:
stages:
- staging
- production
For each stage defined above, ensure you have a corresponding heroku
app created, and that each heroku
app has a ruby
buildpack added.
Now, for some housekeeping, and ensuring everything's upto date
before_script:
- apt-get update -qy
Now, for each of the stages you defined earlier, describe the ruby version you need.
As of January 2017,
showoff
uses Rubyv2.2.6
, update the image after checking the Ruby documentation
Add the $HEROKU_APP-NAME
and the $HEROKU_API_KEY
for each stage.
staging:
image: ruby:2.2
stage: staging
script:
- gem install dpl
- dpl --provider=heroku --app=$HEROKU_APP-NAME --api-key=$HEROKU_PRODUCTION_API_KEY --strategy=git
only:
- staging
production:
image: ruby:2.2
stage: production
script:
- gem install dpl
- dpl --provider=heroku --app=gitlab-ci-ruby-test-prod --api-key=$HEROKU_PRODUCTION_API_KEY --strategy=git
only:
- master
The complete script looks like this:
stages:
- staging
- production
before_script:
- apt-get update -qy
staging:
image: ruby:2.2
stage: staging
script:
- gem install dpl
- dpl --provider=heroku --app=gitlab-ci-ruby-test-prod --api-key=$HEROKU_PRODUCTION_API_KEY --strategy=git
only:
- staging
production:
image: ruby:2.2
stage: production
script:
- gem install dpl
- dpl --provider=heroku --app=gitlab-ci-ruby-test-prod --api-key=$HEROKU_PRODUCTION_API_KEY --strategy=git
only:
- master
Upvotes: 2