Skip to content

PierreRAFFA/cancel-previous-runs-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cancel Previous Runs Action

This GitHub action is responsible to cancel any previous runs for the current workflow or from a given list.
It supports 3 events:

  • pull_request
  • push
  • merge_group

Requirements

  • gh (comes natively with Github-hosted runners) + write permissions to setup in the repo settings
  • jq

Event Handlers

For pull_request and push events, the cancellation is performed for previous runs:

  • which are in_progress or queued state
  • from the same workflow, or from a given list of workflows or from any workflow
  • from the same branch
  • older than the current run

For merge_group event, the cancellation is performed for previous runs:

  • which are in_progress or queued state
  • from the same workflow, or from a given list of workflows or from any workflow
  • related to the same PR
  • older than the current run

The cancellation of the previous runs could be required when:

  • the merge queue has entries running concurrently
  • the first entry fails and all the next ones will have to run again
    This result in multiple runs executed for the same queued PR.

Usage

Place this job at the beginning of your workflow.
Once the job running, it will check for all runs related to the same context than the current run and cancel all of them.

Cancel previous runs from the same workflow:

jobs:
  cancel-previous-runs:
    runs-on: ubuntu-latest
    steps:
      - name: Cancel Previous Runs
        uses: pierreraffa/cancel-previous-runs-action@1.11

Cancel previous runs from a list of workflows:

jobs:
  cancel-previous-runs:
    runs-on: ubuntu-latest
    steps:
      - name: Cancel Previous Runs
        uses: pierreraffa/cancel-previous-runs-action@1.11
        with:
          workflow_names: Workflow1,Workflow2

Cancel previous runs from all workflows of the repository:

jobs:
  cancel-previous-runs:
    runs-on: ubuntu-latest
    steps:
      - name: Cancel Previous Runs
        uses: pierreraffa/cancel-previous-runs-action@1.11
        with:
          workflow_names: '*'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages