[英]Cancel current running workflow from Github Actions
我希望能夠根據條件取消我當前運行的workflow
。
我試着像這樣使用 這個動作
- name: cancel workflow if none of files we look for changes has not changed
if: steps.changed-files.outputs.any_changed != 'true'
uses: styfle/cancel-workflow-action@0.10.0
with:
workflow_id: ${{ github.workflow_id }}
access_token: ${{ github.token }}
但從日志中可以看出:
Found token: yes
Found workflow_id: ["12345567"]
Found 3 runs total.
Found 0 runs to cancel.
它只會取消其他同時運行的工作流。
有沒有簡單的方法解決這個問題,還是我應該求助於 GH API?
編輯:我已經在應該取消工作流的 rest 的步驟中嘗試了這個
gh api --method POST -H "Accept: application/vnd.github+json" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel
但是它只返回一個{}
並繼續執行......
這是 go 關於它的一種方法
- name: cancel run if none of files we look for changes has changed
if: steps.changed-files.outputs.any_changed != 'true'
uses: andymckay/cancel-action@0.2
# needed since the run is not cancelled immediately
- name: wait for run cancellation
if: steps.changed-files.outputs.any_changed != 'true'
shell: bash
run: while true; do echo "Waiting for job to be cancelled"; sleep 5; done
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.