Skip to content

Commit 1e52bb1

Browse files
authored
Update manage-encrypted-secrets.md
1 parent 7f99f69 commit 1e52bb1

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

learn-pr/github/manage-github-actions-enterprise/includes/manage-encrypted-secrets.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,73 @@ If you need to access the encrypted secret in your action's code, the action cod
6161
<!-- INFOMAGNUS UPDATES for all of sub OD 4.3 go here! Source Material:https://www.google.com/url?q=https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions&sa=D&source=editors&ust=1742484244534691&usg=AOvVaw30HJhmh-nnnssWIlwRCI_5 -->
6262

6363
<!-- Test -->
64+
=======
65+
66+
### Access Encrypted Secrets Within Actions and Workflows
67+
68+
#### Example: Using a Secret in a Workflow
69+
70+
```yaml
71+
name: Deploy Application
72+
73+
on:
74+
push:
75+
branches:
76+
- main
77+
78+
jobs:
79+
deploy:
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Checkout repository
83+
uses: actions/checkout@v3
84+
85+
- name: Use secret in a script
86+
run: echo "Deploying with API_KEY=${{ secrets.DEPLOYMENT_KEY }}"
87+
```
88+
89+
#### Best Practices for Using Secrets in Workflows
90+
- **Do not print secrets** in logs using `echo ${{ secrets.SECRET_NAME }}`.
91+
- **Use secrets within script commands**, rather than assigning them to environment variables.
92+
- **Limit access** by defining secrets at the **lowest necessary level**.
93+
- **Rotate secrets periodically** and update workflows accordingly.
94+
95+
## How to Use third party Vaults
96+
97+
Many enterprises integrate GitHub Actions with external secret management solutions like **HashiCorp Vault, AWS Secrets Manager, and Azure Key Vault**.
98+
99+
### 1. HashiCorp Vault
100+
```yaml
101+
- name: Fetch secret from Vault
102+
id: vault
103+
uses: hashicorp/vault-action@v2
104+
with:
105+
url: https://vault.example.com
106+
token: ${{ secrets.VAULT_TOKEN }}
107+
secret: secret/data/github/my-secret
108+
```
109+
110+
### 2. AWS Secrets Manager
111+
```yaml
112+
- name: Retrieve AWS Secret
113+
run: |
114+
SECRET_VALUE=$(aws secretsmanager get-secret-value --secret-id my-secret | jq -r .SecretString)
115+
echo "SECRET_VALUE=${SECRET_VALUE}" >> $GITHUB_ENV
116+
```
117+
118+
### 3. Azure Key Vault
119+
```yaml
120+
- name: Retrieve Azure Secret
121+
uses: Azure/get-keyvault-secrets@v1
122+
with:
123+
keyvault: "my-keyvault"
124+
secrets: "my-secret"
125+
azureCredentials: ${{ secrets.AZURE_CREDENTIALS }}
126+
```
127+
128+
### Benefits of Using Third-Party Vaults
129+
- **Centralized secret management** reduces security risks.
130+
- **Automated secret rotation** helps comply with security policies.
131+
- **Audit logs and access control** enhance security monitoring.
132+
- **Least privilege access** prevents unauthorized use of secrets.
133+
<!-- Test -->

0 commit comments

Comments
 (0)