Skip to content

Instantly share code, notes, and snippets.

@jahrmando
Created September 9, 2021 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahrmando/fee81b122eab76fdd09781fdf8e477ef to your computer and use it in GitHub Desktop.
Save jahrmando/fee81b122eab76fdd09781fdf8e477ef to your computer and use it in GitHub Desktop.
Script bash to load .env file to Github Secrets
#!/bin/bash
## Usage: ./load_envs_secrets.sh PREFIX(optional)
##
##
PREFIX=${1:-""}
while read SECRT ; do
if [[ $SECRT =~ ^([A-Z0-9_]*)=(.*) ]]; then
S_KEY=${PREFIX}${BASH_REMATCH[1]}
S_VALUE=${BASH_REMATCH[2]}
echo "Loading value secret: $S_KEY -> $S_VALUE"
gh secret set $S_KEY -b"${S_VALUE}"
sleep 2
fi
done < .env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment