-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathaction.yml
27 lines (24 loc) · 1.3 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
name: Cancel Workflow
description: >
Cancels the current workflow run, i.e. all jobs. Useful if you want to cancel the rest of the workflow when one job
fails. Note that this will cause the workflow to appear cancelled, not failed.
# Cancelling the workflow in a post-script (like this:
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runspost; can also be done with
# this action: https://github.com/webiny/action-post-run, see Git history of this file) wouldn't help the status, it
# would still be cancelled. It actually indeed is, but it would be nicer to set it to failed, but there seems to be no
# way to do this.
runs:
using: composite
steps:
- name: Setup Scripts
shell: pwsh
run: |
(Resolve-Path '${{ github.action_path }}/../../../Scripts').Path >> $Env:GITHUB_PATH
- name: Cancel Workflow
# Fork PRs won't have a token with write access to Actions, thus won't be able to cancel the workflow.
if: github.event.pull_request == '' || github.event.pull_request.head.repo.fork == false
shell: pwsh
run: |
Write-Output "::error::Canceling workflow due to one of the jobs failing."
# See https://cli.github.com/manual/gh_run_cancel
gh run cancel --repo ${{ github.repository }} ${{ github.run_id }}