简体   繁体   English

Github 动作 如果失败则拒绝动作

[英]Github actions decline action if fails

I'm trying to use the github actions for first time, I've created and followed the tutorial from github and my .github/workflows/push_main.yml is:我第一次尝试使用 github 动作,我创建并遵循了 github 的教程,我的.github/workflows/push_main.yml是:

name: Android CI
on:
  push:
    branches: [ main ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1

      - name: set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 11

      # Runs ktlint
      - name: Lint
        run: ./gradlew ktlintCheck

      # Execute unit tests
      - name: Unit Test
        run: ./gradlew testDebugUnitTest

Also what I'd like to have is when trying to do a rebase or merge to main have this check and if it works then keep the action of rebase or merge I thought to do something like, create a temporal branch do the check there and if it works do the rebase or merge into main and then delete the temporal branch but I don't know if there's any other efficient way to do so.另外我想要的是,当尝试做一个变基或合并到main时,有这个检查,如果它有效,那么保持rebasemerge的动作,我想做类似的事情,创建一个临时分支在那里做检查和如果它有效,请执行rebasemerge到 main 然后删除时间分支,但我不知道是否有任何其他有效的方法可以这样做。 Also I've seen that I can run the jobs in parallel will it make it faster?我还看到我可以并行运行这些作业会使其更快吗?

This is because jcenter.bintray.com is not working right now, wait, it will work soon这是因为 jcenter.bintray.com 现在不工作,等等,它很快就会工作

There is a super convenient way to build, test and aggregate the outcome of changes of some branch before merging using pull requests.在使用拉取请求合并之前,有一种超级方便的方法可以构建、测试和汇总某些分支的更改结果。

Its common to create a pull request and trigger a workflow doing the checks.创建拉取请求并触发执行检查的工作流很常见。 Just add "pull_request:" to reuse your existing workflow, to build and test your changes.只需添加“pull_request:”即可重用您现有的工作流程,构建和测试您的更改。

name: Android CI
on:
  push:
    branches: [ main ]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1

      - name: set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 11

      # Runs ktlint
      - name: Lint
        run: ./gradlew ktlintCheck

      # Execute unit tests
      - name: Unit Test
        run: ./gradlew testDebugUnitTest

Jobs are executed in parallel.作业是并行执行的。 Of course that is faster.当然这样更快。 Common use case is a matrix that defines required test targets, eg os versions, node or Java versions.常见用例是定义所需测试目标的矩阵,例如操作系统版本、 节点或 Java 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM