Skip to content

Do While Not Queued

Actions

About

Repetitively execute the specified command until the specified workflow is queued
v2.0.43
Latest
Star (1)

Tags

 (1)

.github/workflows/main.yml

do-while-not-queued

This action allows repetitively executing the specified command until the specified action is queued. This can be handy in building a reliability run where you want to run the same part of a work flow many times.

You can think of this as operating with the following pseudocode

count = 0
endTime = [now-sec] + [$max-time-seconds: default = 2700]
while(true)
{
    for (i = 0; i < [$check-every: default = 1] ;i++)
    {
        count++
        if (count > [$max-runs: default = 1000])
        {
            return
        }

        if (Run [$command-line] With [$args] Does Not yield Exit Code 0)
        {
            return
        }

        if ([now-sec] > endTime)
        {
            return
        } 
    }

    if (Was Another Run Of This Workflow Has Been Queued)
    {
        return
    }
}

A few things to note:

  1. You can use this to create runs that go for a long time, and in turn consume a lot of your compute resources, so consider using this with Self-Hosted runners
  2. No timeout is imposed on your command, max-time-seconds only controls how long the action will look for queued items, you need to ensure your command will complete in a reasonable amount of time.
  3. Your command will have access to all Environment variables that are available to actions by default, plus any that add to env:
  4. To perform various operations (like check if a new instance of this workflow has been queued) requires a valid token.

Example Usage

uses: boxofyellow/do-while-not-queued@v2
with:
    # Start up powershell
    command-line: 'pwsh'
    # Pass it two parameter -command Start-Sleep -Second 2
    args: '-command;Start-Sleep -Seconds 2'
    # Use the provided github variable for the work flow
    workflow: ${{ github.WORKFLOW }}
    # Run this for at most 7 iterations
    max-runs: 7
    # If it runs for a total of more than 10 second, stop checking for new instances and exit
    max-time-seconds: 10
    # Use the provided github variable
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Do While Not Queued is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Repetitively execute the specified command until the specified workflow is queued
v2.0.43
Latest

Tags

 (1)

Do While Not Queued is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.