All Projects → styfle → Cancel Workflow Action

styfle / Cancel Workflow Action

Licence: mit
⏹️ GitHub Action to cancel previous running workflows on push

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to Cancel Workflow Action

mdw
centurylinkcloud.github.io/mdw/
Stars: ✭ 44 (-88.51%)
Mutual labels:  workflows
user guide
The CWL v1.0 user guide
Stars: ✭ 20 (-94.78%)
Mutual labels:  workflows
formulize
Unified data management. One system to handle all data entry, collection, and reporting, across all your unique workflows. Simplify processes. Make people happy.
Stars: ✭ 21 (-94.52%)
Mutual labels:  workflows
jobflow
jobflow is a library for writing computational workflows.
Stars: ✭ 21 (-94.52%)
Mutual labels:  workflows
flytectl
A cross platform CLI for Flyte. Written in Golang. Offers an intuitive interface to Flyte https://docs.flyte.org/projects/flytectl/en/latest/
Stars: ✭ 23 (-93.99%)
Mutual labels:  workflows
memer-action
A GitHub Action for Programmer Memes xD
Stars: ✭ 21 (-94.52%)
Mutual labels:  workflows
nrwl-nx-action
A GitHub Action to wrap Nrwl Nx commands in your workflows.
Stars: ✭ 163 (-57.44%)
Mutual labels:  workflows
Gh Action Pypi Publish
GitHub Action, for publishing distribution files to PyPI
Stars: ✭ 317 (-17.23%)
Mutual labels:  workflows
pull-request-comment-branch
A GitHub Action to get the head ref and sha of a pull request comment
Stars: ✭ 21 (-94.52%)
Mutual labels:  workflows
Tesseract
A set of libraries for rapidly developing Pipeline driven micro/macroservices.
Stars: ✭ 20 (-94.78%)
Mutual labels:  workflows
codeflare
Simplifying the definition and execution, scaling and deployment of pipelines on the cloud.
Stars: ✭ 163 (-57.44%)
Mutual labels:  workflows
flytekit
Extensible Python SDK for developing Flyte tasks and workflows. Simple to get started and learn and highly extensible.
Stars: ✭ 82 (-78.59%)
Mutual labels:  workflows
pyaoscx
Python modules for AOS-CX
Stars: ✭ 24 (-93.73%)
Mutual labels:  workflows
Niffler
Niffler: A DICOM Framework for Machine Learning and Processing Pipelines.
Stars: ✭ 52 (-86.42%)
Mutual labels:  workflows
modules
Repository to host tool-specific module files for the Nextflow DSL2 community!
Stars: ✭ 94 (-75.46%)
Mutual labels:  workflows
ssh2actions
Connect to GitHub Actions VM via SSH for interactive debugging
Stars: ✭ 62 (-83.81%)
Mutual labels:  workflows
nactivity
workflow engine activity activiti
Stars: ✭ 55 (-85.64%)
Mutual labels:  workflows
Actions
A collection of useful GitHub Actions
Stars: ✭ 383 (+0%)
Mutual labels:  workflows
Cadence Web
Web UI for visualizing workflows on Cadence
Stars: ✭ 261 (-31.85%)
Mutual labels:  workflows
Open-Data-Lab
an initiative to provide infrastructure for reproducible workflows around open data
Stars: ✭ 26 (-93.21%)
Mutual labels:  workflows

Cancel Workflow Action

This is a GitHub Action that will cancel any previous runs that are not completed for a given workflow.

This includes runs with a status of queued or in_progress.

How does it work?

When you git push, this GitHub Action will capture the current Branch and SHA. It will query GitHub's API to find previous workflow runs that match the Branch but do not match the SHA. These in-progress runs will be canceled leaving only the latest run.

Read more about the Workflow Runs API.

Usage

Typically, you will want to add this action as the first step in a workflow so it can cancel itself on the next push.

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Cancel Previous Runs
        uses: styfle/[email protected]
        with:
          access_token: ${{ github.token }}
      #- name: Run Tests
      #  uses: actions/[email protected]
      #  run: node test.js
      # ... etc

Advanced: Canceling Other Workflows

In some cases, you may wish to avoid modifying all your workflows and instead create a new workflow that cancels your other workflows. This can be useful when you have a problem with workflows getting queued.

  • Visit https://api.github.com/repos/:org/:repo/actions/workflows to find the Workflow ID(s) you wish to automaticaly cancel.
  • Add a new file .github/workflows/cancel.yml with the following:
name: Cancel
on: [push]
jobs:
  cancel:
    name: 'Cancel Previous Runs'
    runs-on: ubuntu-latest
    timeout-minutes: 3
    steps:
      - uses: styfle/[email protected]
        with:
          workflow_id: 479426
          access_token: ${{ github.token }}
  • Note: workflow_id can be a Workflow ID (number) or Workflow File Name (string)
  • Note: workflow_id also accepts a comma separated list if you need to cancel multiple workflows

Advanced: Pull Requests from Forks

The default GitHub token access is unable to cancel workflows for pull_request when a pull request is opened from a fork. Therefore, a special setup using workflow_run, which also works for push, is needed. Create a .github/workflows/cancel.yml with the following instead and replace "CI" with the workflow name that contains the pull_request workflow:

name: Cancel
on:
  workflow_run:
    workflows: ["CI"]
    types:
      - requested
jobs:
  cancel:
    runs-on: ubuntu-latest
    steps:
    - uses: styfle/[email protected]
      with:
        workflow_id: ${{ github.event.workflow.id }}

Advanced: Ignore SHA

In some cases, you may wish to cancel workflows when you close a Pull Request. Because this is not a push event, the SHA will be the same, so you must use the ignore_sha option.

on:
  pull_request:
    types: [closed]
jobs:
  cleanup:
    name: 'Cleanup After PR Closed'
    runs-on: ubuntu-latest
    timeout-minutes: 3
    steps:
      - name: Cancel build runs
        uses: styfle/[email protected]
        with:
          ignore_sha: true
          workflow_id: 479426

Contributing

  • Clone this repo
  • Run yarn install
  • Edit ./src/index.ts
  • Run yarn build
  • Commit changes including ./dist/index.js bundle
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].