LinuxCommandLibrary

gh-workflow

Manage GitHub Actions workflows

TLDR

Interactively select a workflow to view the latest jobs for

$ gh workflow view
copy

View a specific workflow in the default browser
$ gh workflow view [id|workflow_name|filename.yml] [[-w|--web]]
copy

Display the YAML definition of a specific workflow
$ gh workflow view [id|workflow_name|filename.yml] [[-y|--yaml]]
copy

Display the YAML definition for a specific Git branch or tag
$ gh workflow view [id|workflow_name|filename.yml] [[-r|--ref]] [branch|tag_name] [[-y|--yaml]]
copy

List workflow files (use --all to include disabled workflows)
$ gh workflow [[ls|list]]
copy

Run a manual workflow with parameters
$ gh workflow run [id|workflow_name|filename.yml] [--raw-field param1=value1 --raw-field param2=value2 ...]
copy

Run a manual workflow using a specific branch or tag with JSON parameters from stdin
$ echo '[{"param1": "value1", "param2": "value2", ...]}' | gh workflow run [id|workflow_name|filename.yml] [[-r|--ref]] [branch|tag_name]
copy

Enable or disable a specific workflow
$ gh workflow [enable|disable] [id|workflow_name|filename.yml]
copy

SYNOPSIS

gh workflow <list|view|run|disable|enable|delete> [flags]

PARAMETERS

list
    List all workflows in the repository

--limit <int>
    Maximum number of workflows to list (default 20)

view [<workflow>]
    View the latest run details of a workflow

--job-log
    Include job logs in the output

--log-failed
    Include logs for failed jobs only

--log-all
    Include logs for all jobs

run [<workflow>]
    Run a workflow manually

--field <key>:<value>
    Add custom input to workflow (repeatable)

--ref <ref>
    Reference branch/tag for the workflow

--detach
    Do not wait for workflow completion

disable [<workflow>]
    Disable a workflow from running

--force
    Skip confirmation prompt

enable [<workflow>]
    Re-enable a previously disabled workflow

delete [<workflow>]
    Permanently delete a workflow file

--repo [<HOST/>]<OWNER/REPO>
    Operate on specified repository (global flag)

--json <fields>
    Output JSON data (available on list/view)

DESCRIPTION

The gh workflow command is part of the GitHub CLI toolset, allowing users to interact with GitHub Actions workflows directly from the terminal. It provides subcommands to list, view, run, enable, disable, or delete workflows in a repository.

Workflows are YAML files defining CI/CD pipelines in GitHub repositories. This command streamlines repository management without needing a web browser, ideal for automation scripts, local development, and CI environments.

Key features include listing all workflows with pagination, viewing detailed run logs (including failed jobs), manually triggering workflow runs with custom inputs, and toggling workflow states. It supports JSON output for scripting and integrates seamlessly with other gh commands like gh run for job management.

Requires GitHub CLI installed (gh) and authentication via gh auth login. Operates on the current repository by default or a specified one via --repo. Supports GitHub Enterprise with appropriate flags.

CAVEATS

Requires gh auth login; limited to repositories with access permissions. No support for organization-level workflows. Workflow runs consume GitHub minutes quotas.

EXAMPLES

gh workflow list
gh workflow view ci.yml --job-log
gh workflow run --field environment=prod

AUTHENTICATION

Run gh auth login first. Supports GitHub.com, Enterprise, and PATs.

HISTORY

Introduced in GitHub CLI v0.5.0 (February 2020) alongside Actions support. Expanded in v2.x with JSON output, log viewing, and detach options. Actively maintained by GitHub.

SEE ALSO

gh(1), gh-run(1), gh-repo(1), git(1)

Copied to clipboard