簡體   English   中英

Github 操作 作業被跳過

[英]Github Actions Job being skipped

對某些 CI/CD 使用 Github 操作。

目前,我遇到了奇怪的行為,盡管條件得到滿足,但我的工作卻被跳過了。 deploy-api有兩個條件,如果代碼被推送到 master 並且test-api是成功的。 但即使我們滿足了這些條件,它仍然被跳過。

jobs:
  test-api:
    name: Run tests on API
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - name: Get dependencies
        run: npm install
        working-directory: ./api
      - name: Run tests
        run: npm run test
        working-directory: ./api

  deploy-api:
    needs: test-api # other job must finish
    if: github.ref == 'refs/heads/master' && needs.test-api.status == 'success' #only run if it's a commit to master AND previous success

在此處輸入圖像描述

如圖所示,盡管推送在主分支上(如頂部所示)並且前一個作業成功,但第二個作業被跳過。

我在代碼中遺漏了什么嗎? 有誰知道可以使用的解決方法?

如果 UI 告訴用戶它被跳過的原因,那就太好了!

if表達式中使用needs.test-api.result == 'success' (沒有.status )。

請參閱https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM