Skip to content

🎟️A GitHub Action for serializing workflow runs

License

Notifications You must be signed in to change notification settings

highfidelity/turnstyle

 
 

Repository files navigation

🎟️
turnstyle

A GitHub Action for serializing workflow runs


🤔 why bother

GitHub Actions is an event-oriented system. Your workflows run in response to events and are triggered independently and without coordination. In a shared repository, if two or more people merge pull requests, each will trigger workflows without regard to one another.

This can be problematic for workflows used as part of a continuous deployment process. You might want to let an in-flight deployment complete before progressing further with the next workflow. This is the usecase turnstyle action targets.

🤸 Usage

The typical setup for turnstyle involves adding job step using softprops/turnstyle@v1.

name: Main

on: push

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
+     - name: Turnstyle
+       uses: softprops/turnstyle@v1
+       env:
+         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Deploy
        run: sleep 30

Timing out

To avoid waiting prolonged periods of time, you may wish to bail on a run or continuing a workflow run regardless of the status of the previous run.

You can bail from a run using the built-in GitHub Actions jobs.<job_id>.timeout-minutes setting

name: Main

on: push

jobs:
  main:
+   timeout-minutes: 5
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Turnstyle
        uses: softprops/turnstyle@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Deploy
        run: sleep 30

You can also limit how long a you're willing to wait before moving on with jobs.<job_id>.steps.with.continue-after-seconds

name: Main

on: push

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Turnstyle
        uses: softprops/turnstyle@v1
        with:
+         continue-after-seconds: 180 
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Deploy
        run: sleep 30

inputs

Name Type Description
continue-after-seconds number Maximum number of seconds to wait before moving forward (unbound by default)
poll-interval-seconds number Number of seconds to wait in between checks for previous run completion (defaults to 60)

outputs

None.

environment variables

The following are required as step.env keys

Name Description
GITHUB_TOKEN GITHUB_TOKEN as provided by secrets

cost of coordination

At this time there is no way to coordinate between workflow runs beyond waiting. For those using private repositories, you are charged based on the time your workflow spends running. Waiting within one workflow run for another to complete will incur the cost of the time spent waiting.

Doug Tangren (softprops) 2020

About

🎟️A GitHub Action for serializing workflow runs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.2%
  • JavaScript 2.8%