【发布时间】:2020-05-26 08:02:47
【问题描述】:
我对 Git 和自动化部署非常陌生,我正在尝试将作为 CI 的一部分所做的更改部署到 Heroku。
高层次的想法:
- 将我的代码发送到 GitHub
- CircleCI 将其拾取并进行一些缩小
- CircleCI 运行一些测试
- CircleCI 将我的文件(包括我对它们所做的更改)部署到 Heroku
一切正常,除了我在 Heroku 上获得的文件似乎是来自 Git 的文件,而不是修改/缩小的文件。
我猜问题出在我的 YAML 中:
... build steps
deploy:
docker:
- image: buildpack-deps:trusty
steps:
- checkout
- run:
name: Deploy to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
但是,我不确定如何更改它。
- 将修改后的文件直接发送到 Heroku 是不是不好?我应该先将它们提交到特殊发布文件夹中的 GitHub,然后将其发送到 Heroku?怎么样?
- 这只是我的 YAML 中缺少的东西吗?
完整的 YAML 作为参考:
version: 2
jobs:
build:
docker:
# https://circleci.com/docs/2.0/circleci-images/
- image: circleci/node:10.10
- image: circleci/postgres:10.5-alpine-postgis
environment:
POSTGRES_USER: myproject
POSTGRES_DB: myproject
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
..........
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run:
name: Unit Testing
command: npm run test_unit
- run:
name: Build client files
command: npm run build
- run:
name: API Testing
command: |
npm start &
npm run test_api
deploy:
docker:
- image: buildpack-deps:trusty
steps:
- checkout
- run:
name: Deploy to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
【问题讨论】:
标签: git heroku deployment continuous-deployment circleci