github-actions - 在第一次失败时停止多行 GitHub 操作

标签 github-actions

我们有一个 GitHub Action 来构建我们的应用程序 我们正在使用多行语法。

run: |
  npm install
  npm run test
  npm run e2e
  npm run deploy

如果其中一个命令失败,则继续执行下一个命令并部署应用程序。

有没有办法在第一次失败时中止操作?

最佳答案

您应该尝试“与”运算符 (&&):

run: |
  npm install &&
  npm run test &&
  npm run e2e &&
  npm run deploy

关于github-actions - 在第一次失败时停止多行 GitHub 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62996357/

相关文章:

linux - GitHub Actions 意外的 bash 可读测试结果

ubuntu - 在 github actions ubuntu-latest 上收到 "Cache not found for input keys: cache-playwright-linux-1.20.0"

github-actions - github actions'相当于circle ci的add_ssh_keys是什么

Github 操作 : Git diff master. ..HEAD 致命:没有 merge 基础

docker - GitHub 操作 : How to run test inside container

git - 与本地存储库相比,为什么使用 GitHub 操作时 `git rebase upstream/main` 的行为不同?

azure - 由多个存储库使用的联合凭证 - Github Actions

github-actions - 如何在github actions中的其他运行命令中使用curl的响应

Github 操作 : failed with "lost connection"

github - 如果测试失败github操作如何拒绝拉取请求