Search code examples
gitlabgitlab-cigitlab-ci-runner

gitlab heroku api key securing


I am doing CI/CD with heroku and gitlab but i found it's not secure placing api in gitlab_ci.yml file

My gitlab looks like:

 - dpl --provider=heroku --app=myproject-development --api-key=myapigoesthere

I found another way to do it, like this:

- dpl --provider=heroku --app=myproject-development --api-key=$HEROKU_API_KEY

I found we can give variable this way, but where can i set value of $HEROKU_API_KEY?

Anyone knows it?


Solution

  • There are multiple ways to set CI/CD variables, but you'll specifically want to set it within the project settings as a "masked" variable so it doesn't get printed in job logs.

    So basically, go to your project's Settings > CI/CD and expand the Variables section and set up a variable with:

    • Key: HEROKU_API_KEY
    • Value: (insert your API key)
    • Type: Variable
    • Mask variable: on

    Save.