【发布时间】:2021-02-12 07:30:18
【问题描述】:
使用 CircleCI 部署到 HEROKU 时遇到问题。我已经测试过手动将git push heroku master 部署到heroku,这是可行的。但是,当我使用 CircleCI 时,部署不再有效。
Github 仓库地址:https://github.com/dulerong/vue-test-circleci
我已经在 CircleCI 项目设置中设置了 HEROKU 环境变量。
HEROKU_API_KEY=my_key
HEROKU_APP_NAME=my_app_name
错误信息如下。
#!/bin/bash -eo pipefail
if false;then
force="-f"
fi
heroku_url="https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git"
if [ -n "$CIRCLE_BRANCH" ]; then
git push $force $heroku_url $CIRCLE_BRANCH:main
elif [ -n "$CIRCLE_TAG" ]; then
git push $force $heroku_url $CIRCLE_TAG^{}:main
else
echo "No branch or tag found."
exit 1
fi
fatal: Not a git repository (or any of the parent directories): .git
Exited with code exit status 128
CircleCI received exit code 128
下面是我的circleCI config.yml
version: 2.1
orbs:
heroku: circleci/heroku@1.2.5
jobs:
build-job:
working_directory: ~/repo
docker:
- image: circleci/node:12.18.2
steps:
- checkout
- run:
name: Install dependencies
command: npm install
- run:
name: Build
command: npm run build
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run:
name: lint
command: npm run lint
- run:
name: test
command: npm run test:unit
deploy-job:
working_directory: ~/repo
docker:
- image: circleci/node:12.18.2
steps:
- attach_workspace:
at: ~/repo
- heroku/deploy-via-git
workflows:
version: 2.1
deploy:
jobs:
- build-job
- deploy-job:
requires:
- build-job
filters:
branches:
only: master
- 我已将 CircleCI 链接到我的 Github 存储库
- 我创建了
.circleci folder config.yml - 我在 heroku 上创建了一个应用程序,当我手动部署时它可以工作
- 我的 CircleCI 的构建部分工作,但部署不起作用
任何帮助表示赞赏,在此先感谢。
【问题讨论】: