-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,20 +15,15 @@ jobs: | |
contents: read | ||
|
||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure AWS Credentials Action for GitHub Actions | ||
uses: aws-actions/[email protected] | ||
with: | ||
aws-region: us-east-2 | ||
role-to-assume: arn:aws:iam::975050371175:role/github-sa-role | ||
role-session-name: githubsa | ||
- name: Get secrets | ||
uses: aws-actions/aws-secretsmanager-get-secrets@v1 | ||
with: | ||
secret-ids: | | ||
core/dev/mobile/.env.development.test | ||
# - name: Retrieve envs from AWS Secrets Manager | ||
# run: | | ||
# aws secretsmanager get-secret-value --secret-id "core/dev/mobile/.env.development.test" | ||
|
||
- name: Retrieve envs from AWS Secrets Manager | ||
working-directory: ./packages/core-mobile/scripts/github | ||
run: | | ||
./fetchEnvsFromAWS.sh "core/dev/mobile/.env.development.test" ".env.test" | ||
cat .env.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# Check if the correct number of parameters are provided | ||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 <secret_id> <output_filename>" | ||
exit 1 | ||
fi | ||
|
||
# Retrieve the secret value and assign it to the data variable | ||
data=$(sudo aws secretsmanager get-secret-value --secret-id "$1" | grep "SecretString") | ||
|
||
|
||
# Check if the secret value is empty | ||
if [ -z "$data" ]; then | ||
echo "Error: Failed to retrieve secret value" | ||
exit 1 | ||
fi | ||
|
||
# Extract the secret string value | ||
data=$(echo "$data" | sed 's/.*"SecretString": "\(.*\)".*/\1/') | ||
|
||
# Parse the string to extract key-value pairs | ||
pairs=$(echo "$data" | sed 's/[{}"]//g' | tr ',' '\n' | tr ':' '=') | ||
|
||
# Erase the content of the output file | ||
> "$2" | ||
|
||
# Write the key-value pairs to the output file | ||
echo "$pairs" | while IFS= read -r line; do | ||
echo "$line" | sed 's/\\//g' >> "$2" | ||
done | ||
|
||
echo "envs saved to $2" |