gpt4 book ai didi

github - 为打开的拉取请求跳过 travis.yml 部署?

转载 作者:行者123 更新时间:2023-12-01 23:19:12 24 4
gpt4 key购买 nike

我为拉取请求启用了 Travis 存储库。打开拉取请求时,travis.yml 会触发测试和 deploy 脚本。

我想打开拉取请求以运行所有测试,但除非合并,否则不运行部署脚本。

下面是我的 travis.yml 的示例:

sudo: true
language: node_js
before_deploy:
- wget https://s3.amazonaws.com/go-cli/releases/v6.12.4/cf-cli_amd64.deb -qO temp.deb && sudo dpkg -i temp.deb
- rm temp.deb
- cf login
- cf install-plugin autopilot -r CF-Community
- npm run build
deploy:
- edge: true
provider: script
script: cf zero-downtime-push app-name -f ./manifest.yml
on:
branch: master

最佳答案

您可以使用 travis 特殊环境变量 TRAVIS_PULL_REQUEST 来检测是否为 PR 触发了构建。

所以你的脚本看起来像:

...

deploy:
- edge: true
provider: script
script: if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cf zero-downtime-push app-name -f ./manifest.yml; else echo "PR skip deploy"; fi
on:
branch: master

更多您可以借鉴的 travis 变量:
https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables

关于github - 为打开的拉取请求跳过 travis.yml 部署?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42266188/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com