diff --git a/.circleci/config.yml b/.circleci/config.yml index 9fd9965..4c7c85f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -88,6 +88,7 @@ jobs: name: Install Dependencies command: | npm install node-forge + npm install --global yarn - run: name: Create Decryption Script @@ -122,15 +123,24 @@ jobs: name: Decode secrets and environment variables command: | if [ -n "<< pipeline.parameters.SECRETS >>" ]; then - echo "Decoding secrets..." - DECRYPTED_JSON=$(node ~/project/decrypt.js '<< pipeline.parameters.SECRETS >>') - if [[ $DECRYPTED_JSON == {* ]]; then - echo "$DECRYPTED_JSON" | jq -r 'to_entries | map("export \(.key)=\(.value|@sh)") | .[]' > ~/project/decrypted_secrets.txt - else - echo "export DECRYPTED_SECRET=$DECRYPTED_JSON" > ~/project/decrypted_secrets.txt - fi + echo "Downloading and decoding secrets..." + + # Configure AWS CLI + aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID + aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY + aws configure set default.region $AWS_REGION + + # Download secrets file from S3 + aws s3 cp << pipeline.parameters.SECRETS >> ~/project/encrypted_secrets.json + + # Decrypt the secrets + DECRYPTED_JSON=$(node ~/project/decrypt.js "$(cat ~/project/encrypted_secrets.json)") + + echo "$DECRYPTED_JSON" | jq -r 'to_entries | map("export \(.key)=\(.value|@sh)") | .[]' > ~/project/decrypted_secrets.txt source ~/project/decrypted_secrets.txt - cat ~/project/decrypted_secrets.txt + + # Clean up + rm ~/project/encrypted_secrets.json fi if [ -n "<< pipeline.parameters.ENVIRONMENT_VARIABLES >>" ]; then