Skip to content

Commit

Permalink
try 101
Browse files Browse the repository at this point in the history
  • Loading branch information
AzizMukhtorjonov committed Jun 17, 2024
1 parent 64e38e6 commit 241bcdd
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
SERVER_USER: ${{ secrets.SERVER_USER }}
SERVER_HOST: ${{ secrets.SERVER_HOST }}
KNOWN_HOSTS: ${{ secrets.KNOWN_HOSTS }}
CONFIG_FILE: "applications/main.json"
ENVS: ${{ secrets.ENVS }}

jobs:
build-and-deploy:
Expand All @@ -28,26 +28,7 @@ jobs:

- name: Create .env file from JSON config
run: |
function process_secrets {
local data="$1"
local secrets="$2"
echo "$data" | jq -r 'to_entries[] | "\(.value)=\(.key)"' | while IFS='=' read -r value key; do
export SECRET_KEY="$value"
secret_value=$(jq -r --arg key "$value" '.[$key]' <<< "$secrets")
echo "secret_value: $secret_value"
echo "$value=${{ secrets[format('${0}', 'DATABASE_URL')] }}"
done
}
secrets_from_file=$(cat "$CONFIG_FILE" | jq -r '.secrets')
{
echo "# Environment variables"
jq -r '.envs | to_entries[] | "\(.key)=\(.value)"' "$CONFIG_FILE"
echo
echo "# Secrets"
process_secrets "$(jq -r '.' <<< "$secrets_from_file")" $secrets
} > .env
echo ${{ env.ENVS }} > .env
echo "Created .env file"
Expand Down

0 comments on commit 241bcdd

Please sign in to comment.