简体   繁体   中英

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:

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. 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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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