有涵盖 Ruby 和 Python 应用程序部署的教程,但我找不到 NodeJS 的良好文档或示例。
http://docs.gitlab.com/ce/ci/examples/test-and-deploy-python-application-to-heroku.html http://docs.gitlab.com/ce/ci/examples/test-and-deploy-python-application-to-heroku.html
http://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html http://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html
有谁有.gitlab-ci.yml
分享?
- 创建一个项目
npm init -y
npm i #install dependencies
- 在 package.json 中添加以下行
"engines": {
"node": "8.12.0", //node version
"npm": "6.4.1" //npm version
},
"scripts": {
"start": "node app.js", //heroku will using the following script to run node app
}
-
创建一个heroku项目
- select NEW -> 创建新应用程序
- set the App name & 选择一个地区
- 点击创建应用程序
Gitlab 设置创建新的存储库或添加到 gitlab 网站上给出的现有项目
-
创建 .gitlab-ci.yml 文件
image: node:latest
stages:
- production
production:
type: deploy
stage: production
image: ruby:latest
script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- dpl --provider=heroku --app=APPNAME_OF_Heroku App --api-key=$HEROKU_API_KEY # security add the heroku api to CI/CD setting
only:
- master #branch name to deploy on heroku
- Setting HEROKU_API_KEY
- 设置 -> CI/CD -> 变量 -> 展开
- 在 .gitlab-ci.yml 中输入变量键 -> 变量名称
- 输入变量值 -> Heroku Api Key
-
获取 Heroku Api 密钥
- Heroku 仪表板 -> 帐户设置
-
在Gitlab上设置Runner
- Setting -> CI/CD -> Variable -> Expand
- Specific Runners
- 安装 gitlab-runner
- Windows https://docs.gitlab.com/runner/install/windows.html
- Linux https://docs.gitlab.com/runner/install/linux-manually.html
- MacOS https://docs.gitlab.com/runner/install/osx.html
- 有关设置步骤here https://docs.gitlab.com/runner/register/index.html
- Shared Runners
- 只需点击禁用共享跑步者启用共享运行器
-
将文件推送到gitlab,它会自动部署到heroku上
git add . #to add all the files)
git commit -m "message" #to commit files
git push origin master
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)