gh-actions-cli

module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: MIT

README ΒΆ

gha β€” GitHub Actions CLI

Go Reference Go Report Card Latest release Go version

gha is a CLI for managing the GitHub Actions used across your repositories β€” straight from the terminal:

  • πŸ“Œ Pin actions to immutable commit SHAs (and fail CI on anything unpinned).
  • ⬆️ Interactively update actions to their latest releases.
  • πŸ“Š Analyze workflow run health β€” success rates and durations.

Install

Download a pre-built binary for linux, macOS, or Windows from the releases page, or install with Go:

go install github.com/wille/gh-actions-cli/cmd/gha@latest

Build from source

go build -o gha ./cmd/gha

Usage

gha list [paths...]      # inventory: which actions are pinned and current
gha pin [paths...]       # preview the actions that would be pinned (fails CI if any)
gha pin --yes            # pin them (writes files)
gha update [paths...]    # interactively pick actions to update
gha update --yes         # update every outdated action
gha stats [workflow]     # workflow run success rates and durations

With no paths, gha scans .github/workflows/*.{yml,yaml} and composite action.{yml,yaml} files. Pass paths to narrow the scope.

gha list

A read-only inventory of every action, grouped by workflow file, showing whether each is pinned to a commit SHA (βœ“) or a floating tag (⚠), its current version, and β€” looked up from the GitHub API β€” the latest available version:

.github/workflows/ci.yml
  βœ“ actions/checkout      v7.0.0           pinned Β· up to date
  ⚠ actions/setup-node    v4 β†’ v6.4.0      floating Β· outdated

2 action(s), 1 not pinned.
  • --offline skips the API for an instant pinned/floating-only view.
  • --outdated / --unpinned narrow the list to just those actions.
  • --json emits the inventory as structured JSON.
gha pin

A tag like @v4 is mutable β€” it can be moved to point at different code. gha pin locks each action to the exact commit, keeping the version readable as a comment:

uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4

It previews by default and writes nothing until you pass --yes. Unpinned actions are surfaced with a clear warning:

.github/workflows/ci.yml
  ⚠ actions/checkout  https://github.com/actions/checkout/releases
    current:  v4
    pinned:   08c6903cd8c0fde910a37f88322edcfb5dd907a8  # v4

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 🚨 SECURITY RISK   1 action is NOT pinned to a commit SHA
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Already-pinned actions are left untouched, and your formatting and comments are preserved. Local (./…) and docker://… references are skipped.

gha pin exits non-zero when unpinned actions remain, so you can run it in CI to fail a build that introduces an unpinned action β€” and gha pin --yes in a fix step to lock them down.

gha update

Shows each action's current version next to its latest release, grouped by workflow file. Pick the ones to bump and gha re-pins them to the new version. Toggle a file header to select or deselect all of its actions at once:

Select actions to update (re-pinned to the new version's SHA):
  [~] .github/workflows/ci.yml
β€Ί     [x] actions/checkout   v4 β†’ v7.0.0
      [ ] actions/setup-go   v5 β†’ v6.0.0

Pass --yes to update every outdated action without the prompt β€” handy for scheduled dependency-update jobs.

gha stats

Reports per-workflow run statistics: run count, success rate, p50/p95/slowest duration, and the last run.

actions/checkout Β· branch main Β· since 2026-06-15

WORKFLOW         RUNS  SUCCESS     p50     p95  SLOWEST  LAST
Build and Test    100     99%   2m 28s  3m 40s  6m 02s  βœ“ 2h ago
Dependabot         50     20%   1m 39s   2m 1s   2m 1s  βœ— 4d ago
  • --repo owner/repo β€” target a repo other than the current git remote. A host prefix (ghe.example.com/owner/repo) targets a GitHub Enterprise Server instance.
  • --branch <name> β€” filter runs by branch.
  • --since <window> β€” how far back to analyze runs (default 7d; e.g. 2w, 24h).
  • --jobs β€” per-job breakdown for the slowest workflow.
  • --json β€” machine-readable output.

Durations are wall-clock time, not billable minutes.

Authentication

gha uses the GitHub API and looks for a token in this order:

  1. GITHUB_TOKEN / GH_TOKEN
  2. gh auth token (the GitHub CLI)
  3. unauthenticated β€” works, but with low rate limits
export GITHUB_TOKEN=…

Directories ΒΆ

Path Synopsis
cmd
gha command
Command gha pins, updates, and analyzes GitHub Actions from the command line.
Command gha pins, updates, and analyzes GitHub Actions from the command line.
internal
command
Package command implements the gha subcommands: pin, update, and stats.
Package command implements the gha subcommands: pin, update, and stats.
discover
Package discover finds workflow and composite-action files to process.
Package discover finds workflow and composite-action files to process.
ghclient
Package ghclient wraps go-github with token resolution, an 8-way concurrency cap, and in-flight de-duplication/caching for repeated lookups.
Package ghclient wraps go-github with token resolution, an 8-way concurrency cap, and in-flight de-duplication/caching for repeated lookups.
parse
Package parse extracts and rewrites `uses:` references in workflow/action files while preserving the original formatting byte-for-byte.
Package parse extracts and rewrites `uses:` references in workflow/action files while preserving the original formatting byte-for-byte.
repo
Package repo resolves the target GitHub repository from a flag or git remote.
Package repo resolves the target GitHub repository from a flag or git remote.
stats
Package stats aggregates and formats GitHub Actions workflow run statistics.
Package stats aggregates and formats GitHub Actions workflow run statistics.
ui
Package ui provides terminal styling, hyperlinks, and a progress spinner.
Package ui provides terminal styling, hyperlinks, and a progress spinner.
version
Package version provides SHA detection and semver comparison helpers.
Package version provides SHA detection and semver comparison helpers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL