-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (37 loc) · 1.25 KB
/
secrets-loader.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Instructions to load new secrets
## 1. Add secret names in the workflows_call -> secrets and mark it as required
## 2. Export the secret name with value as JSON in the run section of the "Loading secrets" job
name: Secrets Loader
permissions:
contents: read
on:
workflow_call:
outputs:
encrypted_secrets:
description: "Encrypt loaded secrets in base64 JSON format"
value: ${{ jobs.loading.outputs.encrypted_secrets }}
secrets:
APOLLO_KEY:
required: true
## Add addition secrets here
env:
GHA_GPG_PASSPHRASE: ${{ secrets.GHA_GPG_PASSPHRASE }}
jobs:
loading:
name: loading
runs-on: ubuntu-latest
outputs:
encrypted_secrets: ${{ steps.loading.outputs.encrypted_secrets }}
steps:
- name: Loading secrets
id: loading
run: |
PLAINTEXT_JSON=$(cat <<EOM
{
"APOLLO_KEY": "${{ secrets.APOLLO_KEY }}"
## Add addition secrets here (With comma separated JSON format)
}
EOM
)
ENCRYPTED_SECRET=$(echo "$PLAINTEXT_JSON" | gpg --symmetric --cipher-algo AES256 --batch --yes --passphrase "$GHA_GPG_PASSPHRASE" | base64 | tr -d '\n')
echo "encrypted_secrets=$ENCRYPTED_SECRET" >> $GITHUB_OUTPUT