Skip to content

Commit f356aca

Browse files
titanismlucascosti
andauthored
fix: fixed Actions large secret instructions and added warning (github#18603)
Co-authored-by: Lucas Costi <[email protected]>
1 parent d369d94 commit f356aca

File tree

1 file changed

+42
-26
lines changed

1 file changed

+42
-26
lines changed

content/actions/security-guides/encrypted-secrets.md

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ redirect_from:
77
- /actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
88
- /actions/configuring-and-managing-workflows/using-variables-and-secrets-in-a-workflow
99
- /actions/reference/encrypted-secrets
10+
miniTocMaxHeadingLevel: 3
1011
versions:
1112
fpt: '*'
1213
ghes: '*'
@@ -284,49 +285,64 @@ A workflow created in a repository can access the following number of secrets:
284285
* If the repository is assigned access to more than 100 organization secrets, the workflow can only use the first 100 organization secrets (sorted alphabetically by secret name).
285286
* All 100 environment secrets.
286287
287-
Secrets are limited to 64 KB in size. To use secrets that are larger than 64 KB, you can store encrypted secrets in your repository and save the decryption passphrase as a secret on {% data variables.product.prodname_dotcom %}. For example, you can use `gpg` to encrypt your credentials locally before checking the file in to your repository on {% data variables.product.prodname_dotcom %}. For more information, see the "[gpg manpage](https://www.gnupg.org/gph/de/manual/r1023.html)."
288+
Secrets are limited to 64 KB in size. To store larger secrets, see the "[Storing large secrets](#storing-large-secrets)" workaround below.
289+
290+
### Storing large secrets
291+
292+
To use secrets that are larger than 64 KB, you can use a workaround to store encrypted secrets in your repository and save the decryption passphrase as a secret on {% data variables.product.prodname_dotcom %}. For example, you can use `gpg` to encrypt a file containing your secret locally before checking the encrypted file in to your repository on {% data variables.product.prodname_dotcom %}. For more information, see the "[gpg manpage](https://www.gnupg.org/gph/de/manual/r1023.html)."
288293
289294
{% warning %}
290295
291-
**Warning**: Be careful that your secrets do not get printed when your action runs. When using this workaround, {% data variables.product.prodname_dotcom %} does not redact secrets that are printed in logs.
296+
**Warning**: Be careful that your secrets do not get printed when your workflow runs. When using this workaround, {% data variables.product.prodname_dotcom %} does not redact secrets that are printed in logs.
292297
293298
{% endwarning %}
294299
295-
1. Run the following command from your terminal to encrypt the `my_secret.json` file using `gpg` and the AES256 cipher algorithm.
300+
1. Run the following command from your terminal to encrypt the file containing your secret using `gpg` and the AES256 cipher algorithm. In this example, `my_secret.json` is the file containing the secret.
296301
297-
``` shell
298-
$ gpg --symmetric --cipher-algo AES256 my_secret.json
299-
```
302+
```bash
303+
gpg --symmetric --cipher-algo AES256 my_secret.json
304+
```
300305
301306
1. You will be prompted to enter a passphrase. Remember the passphrase, because you'll need to create a new secret on {% data variables.product.prodname_dotcom %} that uses the passphrase as the value.
302307
303-
1. Create a new secret that contains the passphrase. For example, create a new secret with the name `LARGE_SECRET_PASSPHRASE` and set the value of the secret to the passphrase you selected in the step above.
308+
1. Create a new secret that contains the passphrase. For example, create a new secret with the name `LARGE_SECRET_PASSPHRASE` and set the value of the secret to the passphrase you used in the step above.
309+
310+
1. Copy your encrypted file to a path in your repository and commit it. In this example, the encrypted file is `my_secret.json.gpg`.
311+
312+
{% warning %}
304313
305-
1. Copy your encrypted file into your repository and commit it. In this example, the encrypted file is `my_secret.json.gpg`.
314+
**Warning**: Make sure to copy the encrypted `my_secret.json.gpg` file ending with the `.gpg` file extension, and **not** the unencrypted `my_secret.json` file.
306315
307-
1. Create a shell script to decrypt the password. Save this file as `decrypt_secret.sh`.
316+
{% endwarning %}
308317
309-
``` shell
310-
#!/bin/sh
318+
```bash
319+
git add my_secret.json.gpg
320+
git commit -m "Add new encrypted secret JSON file"
321+
```
322+
323+
1. Create a shell script in your repository to decrypt the secret file. In this example, the script is named `decrypt_secret.sh`.
311324
312-
# Decrypt the file
313-
mkdir $HOME/secrets
314-
# --batch to prevent interactive command
315-
# --yes to assume "yes" for questions
316-
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" \
317-
--output $HOME/secrets/my_secret.json my_secret.json.gpg
318-
```
325+
```bash
326+
#!/bin/sh
327+
328+
# Decrypt the file
329+
mkdir $HOME/secrets
330+
# --batch to prevent interactive command
331+
# --yes to assume "yes" for questions
332+
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" \
333+
--output $HOME/secrets/my_secret.json my_secret.json.gpg
334+
```
319335
320336
1. Ensure your shell script is executable before checking it in to your repository.
321337
322-
``` shell
323-
$ chmod +x decrypt_secret.sh
324-
$ git add decrypt_secret.sh
325-
$ git commit -m "Add new decryption script"
326-
$ git push
327-
```
338+
```bash
339+
chmod +x decrypt_secret.sh
340+
git add decrypt_secret.sh
341+
git commit -m "Add new decryption script"
342+
git push
343+
```
328344
329-
1. From your workflow, use a `step` to call the shell script and decrypt the secret. To have a copy of your repository in the environment that your workflow runs in, you'll need to use the [`actions/checkout`](https://github.com/actions/checkout) action. Reference your shell script using the `run` command relative to the root of your repository.
345+
1. In your {% data variables.product.prodname_actions %} workflow, use a `step` to call the shell script and decrypt the secret. To have a copy of your repository in the environment that your workflow runs in, you'll need to use the [`actions/checkout`](https://github.com/actions/checkout) action. Reference your shell script using the `run` command relative to the root of your repository.
330346
331347
```yaml
332348
name: Workflows with large secrets
@@ -340,7 +356,7 @@ Secrets are limited to 64 KB in size. To use secrets that are larger than 64 KB,
340356
steps:
341357
- uses: {% data reusables.actions.action-checkout %}
342358
- name: Decrypt large secret
343-
run: ./.github/scripts/decrypt_secret.sh
359+
run: ./decrypt_secret.sh
344360
env:
345361
LARGE_SECRET_PASSPHRASE: {% raw %}${{ secrets.LARGE_SECRET_PASSPHRASE }}{% endraw %}
346362
# This command is just an example to show your secret being printed

0 commit comments

Comments
 (0)