Skip to content

Commit

Permalink
adding documentation for gh secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
blastdan committed Mar 12, 2024
1 parent 1cfd20f commit 192ad52
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/gh-secrets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
If you're aiming to use the GitHub CLI (`gh`) with the intent of not storing the secret value directly in your local repository or GitHub, and you'd like to utilize the `gh secret set` command with the `--no-store` option, here’s how you can proceed. This method involves setting a secret for your repository or organization without the need for manually encrypting the secret value on your side, as `gh` handles the encryption for you.

## Encrypting Secret Values Using GitHub CLI

### Setting Secrets Directly with GitHub CLI

To set a secret in a GitHub repository or organization without storing the secret value in the GitHub server, you can use the `gh secret set` command. This command encrypts your secret and sends it securely to GitHub.

1. **Setting a secret for a repository:**

```shell
gh secret set SECRET_NAME --body "secret_value" --repo owner/repo --no-store
```

- Replace `SECRET_NAME` with the name you want to give your secret.
- Replace `"secret_value"` with the actual value of your secret.
- Replace `owner/repo` with the appropriate repository owner and repository name.

2. **Setting a secret for an organization:**

```shell
gh secret set SECRET_NAME --body "secret_value" --org organization --no-store
```

- Replace `SECRET_NAME` with the name you wish to assign to your secret.
- Replace `"secret_value"` with the actual value of your secret.
- Replace `organization` with the name of your GitHub organization.

### Notes on `--no-store` Option

- The `--no-store` option ensures that the secret's value is not stored or logged anywhere on the GitHub server, providing an additional layer of security.
- It's essential to replace `"secret_value"` with the actual value you wish to encrypt and use as a secret. This value is encrypted client-side and securely transmitted to GitHub.

## Conclusion

Using the GitHub CLI with the `--no-store` option for setting secrets is a secure and straightforward method for managing sensitive values in your projects. By integrating these encrypted secrets into your Terraform configurations, you maintain a high level of security and best practices for infrastructure as code.
Binary file added resources/images/secrets/secret-output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 192ad52

Please sign in to comment.