itaied
itaied

Reputation: 7107

CI using Gitlab and Heroku

I'm using react-starter-kit for developing my web application, and Gitlab as my remote git repository.
I want to configure a continuous deployment such that on every push to the master, the npm run deploy script will be executed.

From my local pc, executing npm run deploy builds the node application and push it to the remote heroku git repository. It uses the local credentials on my pc.

I have configured the gitlab runner (in the .yml file) to execute the same npm run deploy, but it fails with Error: fatal: could not read Username for 'https://git.heroku.com': No such device or address. I need to find a way to authenticate the gitlab runner to heroku. I have tried to set env variable HEROKU_API_KEY, but it also didn't work.

How can I push from my gitlab runner to my heroku git repo?

Upvotes: 2

Views: 3114

Answers (1)

Mr.Polymath
Mr.Polymath

Reputation: 67

You should use dlp in your yml. Try something like this in the .gitlab-ci.yml:

before_script:
    - apt-get -qq update
    - npm set progress=false
    - npm install --silent

deploy:
    script:
    - npm run deploy
    - apt-get install -yqq ruby ruby-dev --silent
    - gem install dpl
    - dpl --provider=heroku --app=your-app-name --api-key=$HEROKU_API_KEY
    only:
    - master

You preferaby want to add the env variable $HEROKU_API_KEY from GitLab, not here directly.

Upvotes: 2

Related Questions