diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh new file mode 100755 index 0000000..414919e --- /dev/null +++ b/environment-dotnet/action.sh @@ -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 diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml new file mode 100644 index 0000000..0f01772 --- /dev/null +++ b/environment-dotnet/action.yml @@ -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 }} diff --git a/environment-test-dotnet/action.sh b/environment-test-dotnet/action.sh new file mode 100755 index 0000000..596fb36 --- /dev/null +++ b/environment-test-dotnet/action.sh @@ -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" diff --git a/environment-test-dotnet/action.yml b/environment-test-dotnet/action.yml new file mode 100644 index 0000000..79270da --- /dev/null +++ b/environment-test-dotnet/action.yml @@ -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