Skip to content

Latest commit

 

History

History

workflow-runs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Workflow Runs

Get all workflow runs for a repository.

Usage

var workflowRuns = require( '@stdlib/_tools/github/workflow-runs' );

workflowRuns( opts, clbk )

Gets all workflow runs for a repository.

var opts = {
    'slug': 'stdlib-js/utils-noop'
};

workflowRuns( opts, clbk );

function clbk( error, results, info ) {
    // Check for rate limit information...
    if ( info ) {
        console.error( 'Limit: %d', info.limit );
        console.error( 'Remaining: %d', info.remaining );
        console.error( 'Reset: %s', (new Date( info.reset*1000 )).toISOString() );
    }
    if ( error ) {
        throw new Error( error.message );
    }
    console.log( JSON.stringify( results ) );
    // => <repo_data>
}

The function accepts the following options:

  • slug: GitHub slug of the form :owner/:repo (required).
  • token: GitHub access token.
  • useragent: user agent string.
  • actor: only return workflow runs by the specified user.
  • branch: only return workflow runs associated with a branch.
  • event: only return workflow runs triggered by the specified event.
  • status: only return workflow runs with the specified check run status or conclusion.

To authenticate with GitHub, set the token option.

var opts = {
    'slug': 'stdlib-js/utils-noop',
    'token': 'tkjorjk34ek3nj4!'
};

workflowRuns( opts, clbk );

To specify a user agent, set the useragent option.

var opts = {
    'slug': 'stdlib-js/utils-noop',
    'useragent': 'hello-github!'
};

workflowRuns( opts, clbk );

To only return workflow runs associated with a particular branch, set the branch option.

var opts = {
    'slug': 'stdlib-js/stdlib',
    'branch': 'develop'
};

workflowRuns( opts, clbk );

To only return workflow runs by a certain user (i.e., the user who created the push associated with the check suite or workflow run), set the actor option.

var opts = {
    'slug': 'stdlib-js/stdlib',
    'actor': 'Planeshifter'
};

workflowRuns( opts, clbk );

To only return workflow runs triggered by a certain event, set the event option (see: Events that trigger workflows).

var opts = {
    'slug': 'stdlib-js/stdlib',
    'event': 'workflow_dispatch'
};

workflowRuns( opts, clbk );

To only return workflow runs with the specified check run status or conclusion, set the status option. Available statuses are queued, in_progress, or completed. Possible conclusions are action_required, cancelled, failure, neutral, success, skipped, stale, or timed_out.

var opts = {
    'slug': 'stdlib-js/stdlib',
    'status': 'in_progress'
};

workflowRuns( opts, clbk );

workflowRuns.factory( options, clbk )

Creates a reusable function.

var opts = {
    'slug': 'stdlib-js/utils-noop',
    'token': 'tkjorjk34ek3nj4!'
};

var get = workflowRuns.factory( opts, clbk );

get();
get();
get();
// ...

The factory method accepts the same options as workflowRuns().

Notes

  • Rate limit information includes the following:
    • limit: maximum number of requests a consumer is permitted to make per hour.
    • remaining: number of remaining requests.
    • reset: time at which the current rate limit window resets in UTC seconds.

Examples

var workflowRuns = require( '@stdlib/_tools/github/workflow-runs' );

var opts = {
    'slug': 'stdlib-js/utils-noop',
    'useragent': 'beep-boop-bop'
};

workflowRuns( opts, clbk );

function clbk( error, results, info ) {
    if ( info ) {
        console.error( info );
    }
    if ( error ) {
        throw new Error( error.message );
    }
    console.log( results );
}

CLI

Usage

Usage: ghworkflows [options] (--slug slug | slug)

Options:

  -h,  --help               Print this message.
  -V,  --version            Print the package version.
       --token token        GitHub access token.
       --slug slug          GitHub slug (:owner/:repo).
       --actor              Only return workflow runs by the specified user
       --branch             Only return workflow runs associated with a branch
       --event              Only return workflow runs triggered by the specified
                            event.
       --status             Only return workflow runs with the specified check
                            run status or conclusion.
  -ua, --useragent ua       User agent.

Notes

  • In addition to the token option, the token may also be specified by a GITHUB_TOKEN environment variable. The command-line option always takes precedence.
  • Request resources are written to stdout.
  • Rate limit information is written to stderr.

Examples

Setting the access token using the command-line option:

$ DEBUG=* ghworkflows --token <token> --slug 'stdlib-js/utils-noop'
# => '[{...},{...},...]'

Setting the access token using an environment variable:

$ DEBUG=* GITHUB_TOKEN=<token> ghworkflows --slug 'stdlib-js/utils-noop'
# => '[{...},{...},...]'