仅当TravisCI中的分支为master时才执行脚本

问题描述 投票:1回答:1

我是TravisCI的新手,这可能是一个非常愚蠢的问题,但是我正在尝试编写travis配置,使其仅在当前分支为master时才部署到Firebase。也就是说,仅当将代码推送到主数据库或PR与主数据库合并时,firebase deploy命令才会执行。当将其他分支推入或进行PR时,将执行not deploy命令。这是我到目前为止的内容:

language: node_js
node_js: 12.16.1
script: echo "Running travis-ci"
install: 
  - npm install -g firebase-tools
  - npm i react-scripts
script:
  - yarn add react
  - yarn test
  - if [ "$TRAVIS_BRANCH" = "master" ]; then yarn build; fi
  - if [ "$TRAVIS_BRANCH" = "master" ]; then firebase deploy --project testproj8876 --token $FIREBASE_TOKEN; fi
branches:
  only:
    - master

由于我对这些约定还不太熟悉,所以任何改进/建议也将不胜感激。

reactjs firebase github travis-ci
1个回答
0
投票

Travis直接支持Google Firebase。参见here

因此,我建议使用上面链接中描述的解决方案。

deploy:
  provider: firebase
  token:
   secure: "YOUR ENCRYPTED token"

根据您的情况,您可以检查我的.travis.yml文件here和文档there (Conditional Deployments)中的一个

以下是您所需要的:

deploy:
  cleanup: false
  on:
    branch:
    - master

[如果仍有疑问,请随时提问。否则,请接受我的回答。

欢呼声

© www.soinside.com 2019 - 2024. All rights reserved.