Command Examples for gh workflow (with examples)

Command Examples for gh workflow (with examples)

Interactively select a workflow to view the latest jobs for:

gh workflow view

Motivation: This command allows you to interactively select a workflow from your GitHub repository and view the latest jobs associated with it. This is useful when you want to quickly check the status and progress of your workflows without having to manually navigate through the GitHub UI.

Arguments:

  • None

Example Output: The command will list all the workflows available in your repository along with their IDs, names, and workflow files. You can then select a workflow by entering the corresponding number or typing its name.

View a specific workflow in the default browser:

gh workflow view id|workflow_name|filename.yml --web

Motivation: This command allows you to quickly view a specific workflow in your repository’s default browser. This is useful when you want to see the workflow’s details, including its jobs, runs, and associated artifacts, in a web-based interface.

Arguments:

  • id|workflow_name|filename.yml: The ID, name, or filename of the workflow you want to view.

Example Output: The command will open a new browser tab/window and navigate to the web page displaying the selected workflow.

Display the YAML definition of a specific workflow:

gh workflow view id|workflow_name|filename.yml --yaml

Motivation: This command allows you to quickly view the YAML definition of a specific workflow in your repository. This is useful when you want to inspect the configuration and steps defined in the workflow file.

Arguments:

  • id|workflow_name|filename.yml: The ID, name, or filename of the workflow you want to view.

Example Output: The command will output the YAML definition of the selected workflow directly in the terminal.

Display the YAML definition for a specific Git branch or tag:

gh workflow view id|workflow_name|filename.yml --ref branch|tag_name --yaml

Motivation: This command allows you to view the YAML definition of a specific workflow for a particular Git branch or tag in your repository. This is useful when you want to see how the workflow is configured for different branches or releases.

Arguments:

  • id|workflow_name|filename.yml: The ID, name, or filename of the workflow you want to view.
  • --ref branch|tag_name: The branch or tag name for which you want to view the workflow.

Example Output: The command will output the YAML definition of the selected workflow for the specified branch or tag directly in the terminal.

List workflow files (use --all to include disabled workflows):

gh workflow list

Motivation: This command allows you to list all the workflow files in your repository. This is useful when you want to get an overview of the available workflows and understand the structure of your repository’s CI/CD processes.

Arguments:

  • None

Example Output: The command will list all the workflow files in your repository, along with their names, IDs, and the current status (enabled or disabled).

Run a manual workflow with parameters:

gh workflow run id|workflow_name|filename.yml --raw-field param1=value1 --raw-field param2=value2 ...

Motivation: This command allows you to manually trigger the execution of a specific workflow in your repository with custom parameters. This is useful when you want to test a workflow with different input values or trigger a specific behavior based on runtime variables.

Arguments:

  • id|workflow_name|filename.yml: The ID, name, or filename of the workflow you want to run.
  • --raw-field param1=value1 --raw-field param2=value2 ...: The template parameters and their respective values for the workflow. These will be passed as raw JSON strings.

Example Output: The command will trigger the execution of the selected workflow with the provided parameter values. The output will display the details of the created workflow run, including its ID, status, and progress.

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 --ref branch|tag_name

Motivation: This command allows you to manually trigger the execution of a specific workflow in your repository with custom parameters provided as a JSON object from stdin. This is useful when you want to automate the triggering of workflows and pass dynamic input values from a script or another command.

Arguments:

  • id|workflow_name|filename.yml: The ID, name, or filename of the workflow you want to run.
  • --ref branch|tag_name: The branch or tag name for which you want to run the workflow.

Example Output: The command will read the JSON object with parameter values from stdin and use it to trigger the execution of the selected workflow for the specified branch or tag. The output will display the details of the created workflow run, including its ID, status, and progress.

Enable or disable a specific workflow:

gh workflow enable|disable id|workflow_name|filename.yml

Motivation: This command allows you to enable or disable a specific workflow in your repository. This is useful when you want to control the execution of workflows based on different conditions, such as temporarily disabling a workflow during maintenance or troubleshooting.

Arguments:

  • id|workflow_name|filename.yml: The ID, name, or filename of the workflow you want to enable or disable.

Example Output: The command will enable or disable the selected workflow based on the provided input. The output will display a success message confirming the action.

Related Posts

How to use the command 'git obliterate' (with examples)

How to use the command 'git obliterate' (with examples)

The ‘git obliterate’ command is part of the ‘git-extras’ package and allows for the deletion of specific files and the erasure of their history from a Git repository.

Read More
How to use the command 'head' (with examples)

How to use the command 'head' (with examples)

The ‘head’ command is used to output the first part of files.

Read More
How to use the command 'go run' (with examples)

How to use the command 'go run' (with examples)

The go run command is used to compile and run Go code without saving a binary.

Read More