GitHub CLI provides command-line control over GitHub Actions workflows and repository configuration. Use it to start a named workflow, pass manual-run inputs noninteractively, and manage secrets or variables where command-line access is needed. section 3.3.3 section 3.7
Run a manually dispatchable workflow with `gh workflow run WORKFLOW_FILENAME`. A workflow can be selected by name, ID, or filename; filenames are usually most practical, while names containing spaces require quoting. Use `gh workflow list` to find IDs. section 3.3.3
Supply `workflow_dispatch` inputs in two ways:
- Pass individual values with repeated `-f` or `--field` arguments. section 3.3.3
- Pipe JSON to standard input and use `--json` when inputs already exist as JSON. section 3.3.3
- Expect CLI prompting when required or optional inputs are not supplied directly. section 3.3.3
Run a staged workflow
`gh workflow run MyFirstWorkflow.yml -f homedrive=/home -f logLevel=warning -f tag=true -f environment=Staging` starts a workflow with string, choice, boolean, and environment inputs. Workflow steps read these values through the `inputs` context. section 3.3.3
Use `gh secret set` and `gh variable set` to create repository configuration values. Secrets are encrypted at rest, decrypted only at run time, and masked in workflow logs; variables and secrets may be defined at organization, repository, or environment levels, with lower levels overriding higher ones. section 3.7
$ gh secret set secret-name $ gh variable set var-name
These commands create a secret or variable from the command line; input redirection can provide a secret value from a file, while `--body` sets a variable value directly. section 3.7
