CI/CD

GitHub Actions CLI

GitHub Actions workflow commands and CLI management.

31 commands
Windows MacOS Linux
#automation #github

Workflow Management

List all workflows in the repository
gh workflow list
View details of a specific workflow
gh workflow view deploy.yml
Enable a disabled workflow
gh workflow enable deploy.yml
Disable a workflow
gh workflow disable deploy.yml
Trigger a workflow dispatch event
gh workflow run deploy.yml
Trigger workflow on a specific branch
gh workflow run deploy.yml --ref main

Run Management

List recent workflow runs
gh run list
View details of a specific run
gh run view 12345
Watch a run until it completes
gh run watch 12345
Rerun a failed workflow run
gh run rerun 12345
Cancel an in-progress run
gh run cancel 12345
Download artifacts from a run
gh run download 12345
View logs for a workflow run
gh run view 12345 --log

Cache

List all GitHub Actions caches
gh cache list
Delete all caches for the repository
gh cache delete --all
Delete a specific cache by key
gh cache delete abc123
List caches sorted by size
gh actions-cache list --sort size

Secrets

Set a repository secret interactively
gh secret set MY_SECRET
Set a secret with a value directly
gh secret set MY_SECRET --body value
List all repository secrets
gh secret list
Delete a repository secret
gh secret delete MY_SECRET
Set an environment secret
gh secret set MY_SECRET --env production
List secrets for an environment
gh secret list --env production

Variables

Set a repository variable
gh variable set MY_VAR --body value
List all repository variables
gh variable list
Delete a repository variable
gh variable delete MY_VAR
Set an environment variable
gh variable set MY_VAR --env staging
List variables for an environment
gh variable list --env staging

Quick Commands

Trigger a workflow dispatch event for a specific workflow
gh workflow run deploy.yml
List recent workflow runs with status and conclusions
gh run list
Set a repository secret interactively via stdin
gh secret set MY_SECRET