1GH-SECRET-SET(1) GitHub CLI manual GH-SECRET-SET(1)
2
3
4
6 gh-secret-set - Create or update secrets
7
8
9
11 gh secret set <secret-name> [flags]
12
13
14
16 Set a value for a secret on one of the following levels: - repository
17 (default): available to Actions runs or Dependabot in a repository -
18 environment: available to Actions runs for a deployment environment in
19 a repository - organization: available to Actions runs or Dependabot
20 within an organization - user: available to Codespaces for your user
21
22
23 Organization and user secrets can optionally be restricted to only be
24 available to specific repositories.
25
26
27 Secret values are locally encrypted before being sent to GitHub.
28
29
30
32 -a, --app <string>
33 Set the application for a secret: {actions|codespaces|depend‐
34 abot}
35
36
37 -b, --body <string>
38 The value for the secret (reads from standard input if not spec‐
39 ified)
40
41
42 -e, --env <environment>
43 Set deployment environment secret
44
45
46 -f, --env-file <file>
47 Load secret names and values from a dotenv-formatted file
48
49
50 --no-store
51 Print the encrypted, base64-encoded value instead of storing it
52 on Github
53
54
55 -o, --org <organization>
56 Set organization secret
57
58
59 -r, --repos <repositories>
60 List of repositories that can access an organization or user se‐
61 cret
62
63
64 -u, --user
65 Set a secret for your user
66
67
68 -v, --visibility <string>
69 Set visibility for an organization secret: {all|private|se‐
70 lected}
71
72
73
75 -R, --repo <[HOST/]OWNER/REPO>
76 Select another repository using the [HOST/]OWNER/REPO format
77
78
79
81 # Paste secret value for the current repository in an interactive prompt
82 $ gh secret set MYSECRET
83
84 # Read secret value from an environment variable
85 $ gh secret set MYSECRET --body "$ENV_VALUE"
86
87 # Read secret value from a file
88 $ gh secret set MYSECRET < myfile.txt
89
90 # Set secret for a deployment environment in the current repository
91 $ gh secret set MYSECRET --env myenvironment
92
93 # Set organization-level secret visible to both public and private repositories
94 $ gh secret set MYSECRET --org myOrg --visibility all
95
96 # Set organization-level secret visible to specific repositories
97 $ gh secret set MYSECRET --org myOrg --repos repo1,repo2,repo3
98
99 # Set user-level secret for Codespaces
100 $ gh secret set MYSECRET --user
101
102 # Set repository-level secret for Dependabot
103 $ gh secret set MYSECRET --app dependabot
104
105 # Set multiple secrets imported from the ".env" file
106 $ gh secret set -f .env
107
108
109
110
111
113 gh-secret(1)
114
115
116
117 Jun 2022 GH-SECRET-SET(1)