cli / cli/cli

`gh secret list` should support search by secret name.

Open
#12,346 8 comments 0 reactions 0 assignees View on GitHub
enhancement gh-secret help wanted candidate stale
Dominant language
Go
Stars
46.3k
Forks
9k
Avg merge
2d 6h
Merged PRs (30d)
97

Description

### Describe the feature or problem you’d like to solve

`gh secret list` should support search by secret name. If I want to find all secrets beginning with `CODECOV`, I have to currently iterate through results of `gh secret list`.

### Proposed solution

It would be more efficient if I could just specify search text for secret name as part of `gh secret list` invocation and return the value(s) I am interested in. I believe the REST API for repository secrets does not currently support filtering by secret name but still think this should be handled by CLI.

Either it could be added as an arg: `gh secret list [glob] [flags]` or as a flag: `-S, --search`.

### Additional context

This issue came up at the same time as #12345.

I wanted to list all repos containing secrets whose names start with `ACTION` as I needed to update them due to expiring PATs.

Current:

```powershell
gci -Directory D:\git\ | % { pushd $_.FullName; $repo = (gh repo set-default -v *>&1); $secrets = if($repo -is [string]){gh secret list -R $repo} else {gh secret list}; if ($secrets -and ($secret = $secrets.Where({$_.Contains('ACTION')}))){ Write-Host -ForegroundColor Green $_.FullName; $secret}; popd }
```

Proposed[^1]:

```powershell
gci -Directory D:\git\ | % { pushd $_.FullName; $secrets = gh secret list 'ACTION*' ; if ($secrets){ Write-Host -ForegroundColor Green $_.FullName; $secret}; popd }
```

[^1]: Assumes this issue and #12345 are fixed.

Contributor guide

Open the contributing guide

Research direction

Start with the `gh secret list` command and its existing repository-secrets listing flow; check how the REST API results are received and rendered. Compare the proposed positional glob and `--search` approaches, then verify that matching names such as `ACTION*` are filtered correctly while existing flags still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.