Git

How to Safely Store Secrets in GitHub

GitHub is a code-hosting open-source cloud service utilized as a program version control tool that permits developers to work with other members on projects remotely. Moreover, GitHub is a GUI version of Git as it manages repositories, pull requests, branches, and commits just like Git.

It provides many useful features, and managing secrets is one of them. It manages three types of secrets: Organizational Secrets that can be shareable between different repositories: Repository secrets, whether the organizational repository secret or environment repository secrets, and Environmental Secret, in which you can give access to reviewers to manage secrets.

In this write-up, we will demonstrate how to store secrets on GitHub safely.

How to Safely Store Secrets in GitHub?

To safely store the secrets in GitHub, look at the below-provided procedure.

Step 1: Navigate to GitHub
Firstly, navigate to GitHub’s official website and select the repository in which you want to store the secret:

Step 2: Select Repository Settings
Next, open the repository settings by clicking on the below highlighted “Settings” option:

Step 3: Navigate to the Secret Settings
From the opened menu, navigate to the “Secrets” settings:

Step 4: Create New Repository Secret
After that, hit the “New repository secret” button to save a new secret:

Set the name of the secret. Note that you do not have to use special characters and spaces while setting the secret’s name. However, the underscore can be usable. Add your secret in the “Secret” field and hit the “Add Secret” button:

Here, you can see we have saved the secret safely:

Step 5: Create New Environmental Secret
To save the environmental secret, select the “Environments” settings, scroll down, and click on the “+ Add secret” icon to save the environmental secret:

Set the Secret name, place your secret in the “Value” field, and press the “Add secret” button:

The below output indicates that the environmental secret is stored successfully in GitHub:

We have taught you how to store secrets safely in GitHub.

Conclusion

To store secrets safely on GitHub, first, open the GitHub official website. Next, select the repository where you would like to store the secret. Open the repository settings. Then, visit the Secret “Action” settings from the repository settings and store the new secret. To store environmental secrets, move to the “Environments” settings and hit the “+ Add secret” icon. In this post, we have taught how to store secrets in GitHub safely.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.