The “gh workflow” command is a feature of GitHub CLI (Command-Line Interface) that allows users to interact with GitHub Actions workflows directly from the command line. GitHub Actions is a powerful automation and continuous integration/continuous deployment (CI/CD) platform provided by GitHub.
With the “gh workflow” command, users can perform various operations related to GitHub Actions workflows, including listing workflows, viewing workflow runs and details, and running workflows manually.
Here are some commonly used subcommands with “gh workflow”:
- gh workflow list: This subcommand lists all the workflows available in a repository. It displays information such as the workflow ID, name, and status.
- gh workflow view: This subcommand allows users to view the details of a specific workflow, including the workflow file, associated jobs, and workflow run history.
- gh workflow run: This subcommand triggers a manual run of a specific workflow. Users can specify inputs and other parameters required for the workflow run.
- gh workflow watch: This subcommand enables users to monitor the progress of a workflow run in real-time. It displays live updates of the job statuses and logs as the workflow executes.
Managing workflows through the “gh workflow” command provides a convenient way to interact with GitHub Actions without leaving the command-line environment. It allows users to quickly check the status of workflows, review their configurations, trigger manual runs, and monitor their progress.
GitHub Actions workflows are commonly used for automating various tasks, such as building and testing software, deploying applications, and performing code analysis. The “gh workflow” command provides developers and DevOps teams with a streamlined workflow for managing and interacting with their workflows, making it easier to incorporate automation into their development processes.
It’s important to note that the “gh workflow” command requires appropriate permissions and authentication to access and interact with workflows. Users should ensure they have the necessary privileges and proper authentication set up before using this command.
By providing a command-line interface for GitHub Actions workflows, the “gh workflow” command enhances the efficiency and accessibility of managing workflows. It empowers users to effectively utilize the capabilities of GitHub Actions for automating their development and deployment workflows.
gh workflow Command Examples
1. Interactively select a workflow to view the latest jobs for:
# gh workflow view
2. View a specific workflow in the default browser:
# gh workflow view [id|workflow_name|filename.yml] --web
3. Display the YAML definition of a specific workflow:
# gh workflow view [id|workflow_name|filename.yml] --yaml
4. Display the YAML definition for a specific Git branch or tag:
# gh workflow view [id|workflow_name|filename.yml] --ref branch_or_tag_name --yaml
5. List workflow files (use –all to include disabled workflows):
# gh workflow list
6. Run a manual workflow with parameters:
# gh workflow run [id|workflow_name|filename.yml] --raw-field param1=value1 --raw-field param2=value2
7. 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_or_tag_name
8. Enable or disable a specific workflow:
# gh workflow [enable|disable id|workflow_name|filename.yml]