Skip to content

Commit

Permalink
Merge pull request n1hility#8 from jaikiran/patch-1
Browse files Browse the repository at this point in the history
Include the event that triggered a particular run of a target job
  • Loading branch information
n1hility authored and Joegrundman committed Apr 26, 2021
2 parents 2e3c189 + a96a2fe commit 62e30a9
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 243 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: "build-test"
on: # rebuild any PRs and main branch changes
pull_request:
push:

workflow_dispatch:
repository_dispatch:
jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# cancel-previous-runs

This is just a fork from `n1hility/cancel-previous-runs`, extended to allow additional events be permitted to cancel a run.

This action cancels previous runs for one or more branches/prs associated with a workflow, effectively limiting the resource consumption of the workflow to one per branch.

<p><a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
Expand All @@ -13,7 +16,7 @@ Additionally this action can be placed as an early step in your workflow (e.g. a

token - The github token passed from `${{ secrets.GITHUB_TOKEN }}`. Since workflow files are visible in the repository, **DO NOT HARDCODE A TOKEN ONLY USE A REFERENCE**.
workflow - The filename of the workflow to limit runs on (only applies to schedule events)

events - list of additional events (in addition to the default events of `push` and `pull_request`, e.g. you may add `workflow_dispatch` and/or `repository_dispatch`)

### Schedule Example

Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: 'Cancel Previous Workflow Runs'
description: 'Cancels all previous runs of this workflow'
author: 'n1hility'
author: 'n1hility/Joegrundman'
inputs:
token:
description: The GITHUB_TOKEN secret of this github workflow
required: true
workflow:
description: The filename of the workflow to limit runs on (only applies to schedule events)
required: false
events:
description: list of events that will also allow cancelling of builds (e.g. workflow_dispatch)
required: false
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
Loading

0 comments on commit 62e30a9

Please sign in to comment.