Skip to content
Open
39 changes: 39 additions & 0 deletions environment-dotnet/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

if [ "$GITHUB_REF_NAME" = 'main' ]; then
ENVIRONMENT='prd'
JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/"
elif [ "$GITHUB_REF_NAME" = 'staging' ]; then
ENVIRONMENT='uat'
JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/"
elif [ "$GITHUB_REF_NAME" = 'qa' ]; then
ENVIRONMENT='uat'
JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/"
else
ENVIRONMENT='dev'
JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/"
fi

{
echo ""
if ! [ "$ENVIRONMENT" = "dev" ]; then
echo "ELASTIC_APM_ENABLED: 'true'"
fi
echo "JWT_JWKS_PATH: '$JWT_JWKS_PATH'"
echo "JKS_SAFE_IPS: '$JKS_SAFE_IPS'"
echo "JKS_GOOGLE_PROJECTID: '$GOOGLE_PROJECTID'"
echo "ELASTIC_APM_SERVER_URL: '$ELASTIC_APM_SERVER_URL'"
} > tmpfile

cat ./envs/env-$ENVIRONMENT.yaml tmpfile > merged_temp.yaml
awk '
BEGIN { FS=": " }
!/^[[:space:]]*$/ && !/^#/ {
key = $1
if (!seen[key]) {
print
seen[key] = 1
}
}
' merged_temp.yaml > ./envs/env-$ENVIRONMENT.yaml
rm tmpfile merged_temp.yaml
23 changes: 23 additions & 0 deletions environment-dotnet/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Create Env
description: Create Env

inputs:
ref_name:
required: true
description: ref_name
project_id:
required: true
description: project_id
safe_ips:
required: true
description: safe_ips
runs:
using: composite
steps:
- name: Create Env
shell: bash
run: ${{ github.action_path }}/action.sh
env:
GITHUB_REF_NAME: ${{ inputs.ref_name }}
GOOGLE_PROJECTID: ${{ inputs.project_id}}
JKS_SAFE_IPS: ${{ inputs.safe_ips }}
13 changes: 13 additions & 0 deletions environment-test-dotnet/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

FILE=./envs/env-dev.yaml
while IFS= read -r line
do
if [[ ! $line =~ ^# ]] && [[ $line =~ [^[:space:]] ]]
then
IFS=":" read -r key value <<< "$line"
key=$(echo "$key" | xargs)
value=$(echo "$value" | xargs)
echo "$key=$value" >> "$GITHUB_ENV"
fi
done < "$FILE"
9 changes: 9 additions & 0 deletions environment-test-dotnet/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Create Env
description: Create Env

runs:
using: composite
steps:
- name: Create Env Test
shell: bash
run: ${{ github.action_path }}/action.sh