我正在尝试部署一个使用CRA创建的简单React应用。我创建了应用程序,并使用GitLab作为存储库。然后,我想尝试使用在.gitlab-ci.yml
中创建的配置将其部署到Heroku。我正在尝试关注this tutorial。这是当前的.gitlab-ci.yml
:
# Using the node image to build the React app
image: node:latest
# Announce the URL as per CRA docs
# https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration
variables:
PUBLIC_URL: /my-repo
# Cache node modules - speeds up future builds
cache:
paths:
- node_modules
before_script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
# Name the stages involved in the pipeline
stages:
- test
- build
- deploy
# Job name for gitlab to recognise this results in assets for Gitlab Pages
test:
stage: test
script:
- echo "Running tests"
- npm install
- npm test
build_staging:
stage: build
script:
- echo "Build in staging env"
- npm run build:staging
only:
- staging
build_production:
stage: build
script:
- echo "Build in production env"
- npm run build:production
only:
- master
deploy_staging:
stage: deploy
image: ruby:latest
script:
- echo "Deploy in staging env"
- dpl --provider=heroku --app $HEROKU_APP_STAGING --api-key $HEROKU_API_KEY
only:
- staging
deploy_production:
stage: deploy
image: ruby:latest
script:
- echo "Deploy in production env"
- dpl --provider=heroku --app $HEROKU_APP_PRODUCTION --api-key $HEROKU_API_KEY
only:
- master
但是,当管道尝试在登台中执行部署阶段时,出现此错误:
$ echo "Deploy in staging env"
Deploy in staging env
$ dpl --provider=heroku --app $HEROKU_APP_STAGING --api-key $HEROKU_API_KEY
invalid option "my-app-name"
ERROR: Job failed: exit code 1
我已经在变量中设置了HEROKU_APP_STAGING
和HEROKU_API_KEY
值:
该值不受保护且未屏蔽。而且,我没有在Heroku帐户中使用SSH密钥(以前,我使用SSH密钥,然后尝试删除它,但问题仍然存在)。
以前,在.gitlab-ci.yml
中,我使用dpl --provider=heroku --app=$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY
作为脚本。成功了。没错但是,当我尝试访问该应用程序时,这是错误的。当我做heroku logs
时,它说的是Missing required flags: -a, --app APP app to run command against
。然后,我尝试将其更改为当前的.gitlab-ci.yml
,但随后出现了问题。
这里出了什么问题?