Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for deployment to handle .env parameters from github secret in base64 encoded format #22

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/ecs_deploy_docker_taskdef.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ on:
required: false
default: "staging"
type: string
env_file_secret_var:
required: false
default: ""
type: string
description: "Variable name containing b64 encoded data for .env file"
secrets:
build_params_gh_secret_keys:
required: false
description: "Pass github secrets in json format for supporting docker build"



jobs:
deploy_workflow:
name: Deploy ${{ inputs.app_name }}
Expand Down Expand Up @@ -81,6 +85,13 @@ jobs:
jq -r 'to_entries | .[] | "\(.key)=\(.value)"' secrets.json >> $GITHUB_ENV
fi

- name: Set up secrets from base64 encoded secret to .env file in code directory
run: |
if [[ -n "${{ inputs.env_file_secret_var }}" ]]; then
echo "Fetching and decoding .env file data from secret.${{ inputs.env_file_secret_var }}"
echo "${{ secrets[inputs.env_file_secret_var] }}" | base64 -d > code/.env
fi

- name: Set variables
run: |
if [ "${{ inputs.taskdef_file_script }}" == "local" ]; then
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/npm_build_deploy_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ on:
required: false
default: "staging"
type: string
env_file_secret_var:
required: false
default: ""
type: string
description: "Variable name containing b64 encoded data for .env file"
secrets:
build_params_gh_secret_keys:
required: false
Expand Down Expand Up @@ -61,7 +66,7 @@ jobs:
run: |
if [ -n "${{ secrets.build_params_gh_secret_keys }}" ]; then
echo "${{ secrets.build_params_gh_secret_keys }}" > secrets.json
fi
fi

- name: Parse secrets and set environment variables
run: |
Expand All @@ -70,6 +75,13 @@ jobs:
jq -r 'to_entries | .[] | "\(.key)=\(.value)"' secrets.json >> $GITHUB_ENV
fi

- name: Set up secrets from base64 encoded secret to .env file in code directory
run: |
if [[ -n "${{ inputs.env_file_secret_var }}" ]]; then
echo "Fetching and decoding .env file data from secret.${{ inputs.env_file_secret_var }}"
echo "${{ secrets[inputs.env_file_secret_var] }}" | base64 -d > code/.env
fi

- name: INSTALL
run: npm install

Expand Down
Loading