Why: In a GitHub Organization, it is advised to reduce as much the number of repository administrators, to make governance easier. But there are some functionalities that we need that are only present (visually) for administrators.

In GitHub if you need to manage secrets or variables in a repository or environment, you can do it using the Settings page:

Secrets and Variables Repository Settings
Secrets and Variables Repository Settings

The thing is, you need to have admin rights to the repository, to access the settings page.

Did you know that if you have write permissions, you can also manage these secrets and variables? Yes you can! But not with the GitHub UI (bummer, I know). You can use GitHub API or even better, you can with GitHub CLI.

I not going to explain how to install GitHub CLI (you can find it here) , but will show you examples of using it to set, list and delete secrets and variables in repositories and environments.

Manage secrets and variables in repositories Link to heading

Set secret in repository:

gh secret set MYREPOSECRET --repo <owner/repo>

Set variable in repository:

gh variable set MYREPOVAR --repo <owner/repo>

List secrets in repository:

gh secret list --repo <owner/repo>

List variables in repository:

gh variable list --repo <owner/repo>

Delete secret in repository:

gh secret delete MYREPOSECRET --repo <owner/repo>

Delete variable in repository:

gh variable delete MYREPOVAR --repo <owner/repo>

Manage secrets and variables in environments Link to heading

Set secret in environment:

gh secret set MYENVIRONMENTSECRET --env MYENVIRONMENT --repo <owner/repo>

Set variable in environment:

gh variable set MYENVIRONMENTVAR --env MYENVIRONMENT --repo <owner/repo>

List secrets in environment:

gh secret list --env MYENVIRONMENT --repo <owner/repo>

List variables in environment:

gh variable list --env MYENVIRONMENT --repo <owner/repo>

Delete secret in environment:

gh secret delete MYREPOSECRET --env MYENVIRONMENT --repo <owner/repo>

Delete variable in environment:

gh variable delete MYENVIRONMENTSECRET --env MYENVIRONMENT --repo <owner/repo>

You can learn more about GitHub CLI commands at GitHub CLI manual.

While this is not as user-friendly as a Web UI, most developers nowadays are familiar with and use CLI tools daily.

Hope this enables more agility while using GitHub.