From 3081bec7f59a50e053c4afe2f126fe37bc10221d Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Tue, 7 May 2024 17:08:43 -0300 Subject: [PATCH 01/55] =?UTF-8?q?feat:=20cria=C3=A7=C3=A3o=20de=20nova=20a?= =?UTF-8?q?ction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- environment-dotnet/action.sh | 62 +++++++++++++++++++++++++++++++++++ environment-dotnet/action.yml | 17 ++++++++++ 2 files changed, 79 insertions(+) create mode 100644 environment-dotnet/action.sh create mode 100644 environment-dotnet/action.yml diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh new file mode 100644 index 0000000..098be23 --- /dev/null +++ b/environment-dotnet/action.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +if [ "$GITHUB_REF_NAME" = 'main' ]; then + ENVIRONMENT='prd' + ENVIRONMENT_ELK='production' + ELASTIC_APM_SERVER_URL='http://10.56.0.2:8200' + JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/" +elif [ "$GITHUB_REF_NAME" = 'staging' ]; then + ENVIRONMENT='uat' + ENVIRONMENT_ELK='uat' + ELASTIC_APM_SERVER_URL='http://10.55.0.2:8200' + JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" +else + ENVIRONMENT='dev' + ENVIRONMENT_ELK='develop' + ELASTIC_APM_SERVER_URL='http://10.221.0.114:8200' + JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" +fi + +echo $ENVIRONMENT +echo $ENVIRONMENT_ELK +echo $ELASTIC_APM_SERVER_URL +echo $JWT_JWKS_PATH +echo "$APP_NAME" + +# GOOGLE_PROJECTID="${{ inputs.project_id}}" +# MAX_INSTANCES="${{ inputs.max-instances }}" +# JKS_SAFE_IPS="${{ secrets.JKS_SAFE_IPS }}" +# REGION="${{ inputs.gcp-region }}" + +# APPNAME="${{ inputs.app-name }}" +# VPC_CONNECTOR="vpc-connector-$ENVIRONMENT" + +# # Agrega env +# echo >> ./envs/env-$ENVIRONMENT.yaml +# echo JKS_GOOGLE_PROJECTID: \'$GOOGLE_PROJECTID\' >> ./envs/env-$ENVIRONMENT.yaml +# echo ELASTIC_APM_SERVER_URL: \'$ELASTIC_APM_SERVER_URL\' >> ./envs/env-$ENVIRONMENT.yaml + +# if ! grep -q "JKS_SAFE_IPS:"./envs/env-$ENVIRONMENT.yaml; then +# echo JKS_SAFE_IPS: \'$JKS_SAFE_IPS\' >> ./envs/env-$ENVIRONMENT.yaml +# fi + +# if ! [ "$ENVIRONMENT" = "dev" ]; then +# echo ELASTIC_APM_ENABLED: \'true\' >> ./envs/env-$ENVIRONMENT.yaml +# fi + +# if ! grep -q "JWT_JWKS_PATH:"./envs/env-$ENVIRONMENT.yaml; then +# echo JWT_JWKS_PATH: \'$JWT_JWKS_PATH\' >> ./envs/env-$ENVIRONMENT.yaml +# fi +# if ! grep -q "JKS_ALTERNATIVE_HEADER_FORWARDED_FOR:"./envs/env-$ENVIRONMENT.yaml; then +# echo JKS_ALTERNATIVE_HEADER_FORWARDED_FOR: \'X-Forwarded-For\' >> ./envs/env-$ENVIRONMENT.yaml +# fi + +# echo APPNAME: \'$APPNAME\' >> ./envs/env-$ENVIRONMENT.yaml +# echo JKS_USE_ELASTIC_APM: \'false\' >> ./envs/env-$ENVIRONMENT.yaml +# echo ELASTIC_APM_RECORDING: \'true\' >> ./envs/env-$ENVIRONMENT.yaml +# echo ELASTIC_APM_SERVICE_NAME: \'$APPNAME\' >> ./envs/env-$ENVIRONMENT.yaml +# echo ELASTIC_APM_ENVIRONMENT: \'$ENVIRONMENT_ELK\' >> ./envs/env-$ENVIRONMENT.yaml +# echo ELASTIC_APM_CAPTURE_BODY: \'all\' >> ./envs/env-$ENVIRONMENT.yaml +# echo ELASTIC_APM_CAPTURE_BODY_CONTENT_TYPES: \'*\' >> ./envs/env-$ENVIRONMENT.yaml +# echo ELASTIC_APM_CAPTURE_HEADERS: \'true\' >> ./envs/env-$ENVIRONMENT.yaml +# echo JKS_USE_APM: \'true\' >> ./envs/env-$ENVIRONMENT.yaml \ No newline at end of file diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml new file mode 100644 index 0000000..d8b312e --- /dev/null +++ b/environment-dotnet/action.yml @@ -0,0 +1,17 @@ +name: Create Env +description: Create Env + +inputs: + app_name: + required: true + description: app_name + +runs: + using: composite + steps: + - name: Create Env + shell: bash + run: ${{ github.action_path }}/action.sh + env: + GITHUB_REF_NAME: develop + APP_NAME: ${{ inputs.app_name }} \ No newline at end of file From 15c8a56a1c43b2c8fa9343caf8eb8146818fd636 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Tue, 7 May 2024 18:11:59 -0300 Subject: [PATCH 02/55] ajuste na action --- environment-dotnet/action.sh | 77 ++++++++++++++++------------------- environment-dotnet/action.yml | 23 ++++++++++- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index 098be23..7a49e4c 100644 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -17,46 +17,37 @@ else JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" fi -echo $ENVIRONMENT -echo $ENVIRONMENT_ELK -echo $ELASTIC_APM_SERVER_URL -echo $JWT_JWKS_PATH -echo "$APP_NAME" - -# GOOGLE_PROJECTID="${{ inputs.project_id}}" -# MAX_INSTANCES="${{ inputs.max-instances }}" -# JKS_SAFE_IPS="${{ secrets.JKS_SAFE_IPS }}" -# REGION="${{ inputs.gcp-region }}" - -# APPNAME="${{ inputs.app-name }}" -# VPC_CONNECTOR="vpc-connector-$ENVIRONMENT" - -# # Agrega env -# echo >> ./envs/env-$ENVIRONMENT.yaml -# echo JKS_GOOGLE_PROJECTID: \'$GOOGLE_PROJECTID\' >> ./envs/env-$ENVIRONMENT.yaml -# echo ELASTIC_APM_SERVER_URL: \'$ELASTIC_APM_SERVER_URL\' >> ./envs/env-$ENVIRONMENT.yaml - -# if ! grep -q "JKS_SAFE_IPS:"./envs/env-$ENVIRONMENT.yaml; then -# echo JKS_SAFE_IPS: \'$JKS_SAFE_IPS\' >> ./envs/env-$ENVIRONMENT.yaml -# fi - -# if ! [ "$ENVIRONMENT" = "dev" ]; then -# echo ELASTIC_APM_ENABLED: \'true\' >> ./envs/env-$ENVIRONMENT.yaml -# fi - -# if ! grep -q "JWT_JWKS_PATH:"./envs/env-$ENVIRONMENT.yaml; then -# echo JWT_JWKS_PATH: \'$JWT_JWKS_PATH\' >> ./envs/env-$ENVIRONMENT.yaml -# fi -# if ! grep -q "JKS_ALTERNATIVE_HEADER_FORWARDED_FOR:"./envs/env-$ENVIRONMENT.yaml; then -# echo JKS_ALTERNATIVE_HEADER_FORWARDED_FOR: \'X-Forwarded-For\' >> ./envs/env-$ENVIRONMENT.yaml -# fi - -# echo APPNAME: \'$APPNAME\' >> ./envs/env-$ENVIRONMENT.yaml -# echo JKS_USE_ELASTIC_APM: \'false\' >> ./envs/env-$ENVIRONMENT.yaml -# echo ELASTIC_APM_RECORDING: \'true\' >> ./envs/env-$ENVIRONMENT.yaml -# echo ELASTIC_APM_SERVICE_NAME: \'$APPNAME\' >> ./envs/env-$ENVIRONMENT.yaml -# echo ELASTIC_APM_ENVIRONMENT: \'$ENVIRONMENT_ELK\' >> ./envs/env-$ENVIRONMENT.yaml -# echo ELASTIC_APM_CAPTURE_BODY: \'all\' >> ./envs/env-$ENVIRONMENT.yaml -# echo ELASTIC_APM_CAPTURE_BODY_CONTENT_TYPES: \'*\' >> ./envs/env-$ENVIRONMENT.yaml -# echo ELASTIC_APM_CAPTURE_HEADERS: \'true\' >> ./envs/env-$ENVIRONMENT.yaml -# echo JKS_USE_APM: \'true\' >> ./envs/env-$ENVIRONMENT.yaml \ No newline at end of file +{ + echo "" + if ! [ "$ENVIRONMENT" = "dev" ]; then + echo ELASTIC_APM_ENABLED: \'true\' + fi + echo JKS_ALTERNATIVE_HEADER_FORWARDED_FOR: \'X-Forwarded-For\' + 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\' + echo APPNAME: \'"$APPNAME"\' + echo JKS_USE_ELASTIC_APM: \'false\' + echo ELASTIC_APM_RECORDING: \'true\' + echo ELASTIC_APM_SERVICE_NAME: \'"$APPNAME"\' + echo ELASTIC_APM_ENVIRONMENT: \'$ENVIRONMENT_ELK\' + echo ELASTIC_APM_CAPTURE_BODY: \'all\' + echo ELASTIC_APM_CAPTURE_BODY_CONTENT_TYPES: \'*\' + echo ELASTIC_APM_CAPTURE_HEADERS: \'true\' + echo JKS_USE_APM: \'true\' + +} > 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 \ No newline at end of file diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index d8b312e..2a6a086 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -5,6 +5,21 @@ inputs: app_name: required: true description: app_name + ref_name: + required: true + description: ref_name + project_id: + required: true + description: project_id + max_instances: + required: true + description: max_instances + safe_ips: + required: true + description: safe_ips + gcp_region: + required: true + description: gcp_region runs: using: composite @@ -13,5 +28,9 @@ runs: shell: bash run: ${{ github.action_path }}/action.sh env: - GITHUB_REF_NAME: develop - APP_NAME: ${{ inputs.app_name }} \ No newline at end of file + GITHUB_REF_NAME: ${{ inputs.ref_name }} + APP_NAME: ${{ inputs.app_name }} + GOOGLE_PROJECTID: ${{ inputs.project_id}} + MAX_INSTANCES: ${{ inputs.max_instances }} + JKS_SAFE_IPS: ${{ inputs.safe_ips }} + REGION: ${{ inputs.gcp_region }} \ No newline at end of file From 3252d2b8e79c1b33eaadcaad35a7fd298bc210b3 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Tue, 7 May 2024 18:18:12 -0300 Subject: [PATCH 03/55] add permission --- environment-dotnet/action.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 environment-dotnet/action.sh diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh old mode 100644 new mode 100755 From f92e9b9b34073db1092f0d9bdaf6015b434e7ced Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Tue, 7 May 2024 18:34:01 -0300 Subject: [PATCH 04/55] =?UTF-8?q?corre=C3=A7=C3=A3o=20APPNAME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- environment-dotnet/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index 2a6a086..21ee44c 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -29,7 +29,7 @@ runs: run: ${{ github.action_path }}/action.sh env: GITHUB_REF_NAME: ${{ inputs.ref_name }} - APP_NAME: ${{ inputs.app_name }} + APPNAME: ${{ inputs.app_name }} GOOGLE_PROJECTID: ${{ inputs.project_id}} MAX_INSTANCES: ${{ inputs.max_instances }} JKS_SAFE_IPS: ${{ inputs.safe_ips }} From 05f964e9f64a2cafd09f88132296ee3fcf54ec50 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Wed, 8 May 2024 10:59:50 -0300 Subject: [PATCH 05/55] add platform --- environment-dotnet/action.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index 7a49e4c..ffaa6bb 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -36,6 +36,7 @@ fi echo ELASTIC_APM_CAPTURE_BODY_CONTENT_TYPES: \'*\' echo ELASTIC_APM_CAPTURE_HEADERS: \'true\' echo JKS_USE_APM: \'true\' + echo PLATFORM: \'Clourun\' } > tmpfile From ec6616ead7a3621d36974ddf4cc039a93416a204 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Wed, 8 May 2024 12:12:25 -0300 Subject: [PATCH 06/55] ajuste do nome --- environment-dotnet/action.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index ffaa6bb..dd62fb4 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -36,7 +36,7 @@ fi echo ELASTIC_APM_CAPTURE_BODY_CONTENT_TYPES: \'*\' echo ELASTIC_APM_CAPTURE_HEADERS: \'true\' echo JKS_USE_APM: \'true\' - echo PLATFORM: \'Clourun\' + echo PLATFORM: \'Cloudrun\' } > tmpfile From f285d2c1ce11fd7a999b567d950616b7059582a9 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Wed, 8 May 2024 16:34:07 -0300 Subject: [PATCH 07/55] adicionar environment --- environment-dotnet/action.sh | 2 +- environment-dotnet/action.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index dd62fb4..afe6a40 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -5,7 +5,7 @@ if [ "$GITHUB_REF_NAME" = 'main' ]; then ENVIRONMENT_ELK='production' ELASTIC_APM_SERVER_URL='http://10.56.0.2:8200' JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/" -elif [ "$GITHUB_REF_NAME" = 'staging' ]; then +elif [ "$ENVIRONMENT" = 'staging' ]; then ENVIRONMENT='uat' ENVIRONMENT_ELK='uat' ELASTIC_APM_SERVER_URL='http://10.55.0.2:8200' diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index 21ee44c..e20215c 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -8,6 +8,9 @@ inputs: ref_name: required: true description: ref_name + environment: + required: true + description: environment project_id: required: true description: project_id @@ -29,6 +32,7 @@ runs: run: ${{ github.action_path }}/action.sh env: GITHUB_REF_NAME: ${{ inputs.ref_name }} + ENVIRONMENT: ${{ inputs.environment }} APPNAME: ${{ inputs.app_name }} GOOGLE_PROJECTID: ${{ inputs.project_id}} MAX_INSTANCES: ${{ inputs.max_instances }} From 62476a2b606f589a0b9ed42d512923bf0201dda0 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Wed, 8 May 2024 17:05:10 -0300 Subject: [PATCH 08/55] ajuste nome da variavel --- environment-dotnet/action.sh | 4 ++-- environment-dotnet/action.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index afe6a40..fff4241 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -5,10 +5,10 @@ if [ "$GITHUB_REF_NAME" = 'main' ]; then ENVIRONMENT_ELK='production' ELASTIC_APM_SERVER_URL='http://10.56.0.2:8200' JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/" -elif [ "$ENVIRONMENT" = 'staging' ]; then +elif [ "$ENV" = 'staging' ]; then ENVIRONMENT='uat' ENVIRONMENT_ELK='uat' - ELASTIC_APM_SERVER_URL='http://10.55.0.2:8200' + ELASTIC_APM_SERVER_URL='http://10.221.0.114:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" else ENVIRONMENT='dev' diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index e20215c..19c1d6b 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -32,7 +32,7 @@ runs: run: ${{ github.action_path }}/action.sh env: GITHUB_REF_NAME: ${{ inputs.ref_name }} - ENVIRONMENT: ${{ inputs.environment }} + ENV: ${{ inputs.environment }} APPNAME: ${{ inputs.app_name }} GOOGLE_PROJECTID: ${{ inputs.project_id}} MAX_INSTANCES: ${{ inputs.max_instances }} From b7dfebc13be8598b0fa8e87aed33e9489fafabc8 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Wed, 8 May 2024 17:52:02 -0300 Subject: [PATCH 09/55] ajuste url elk uat --- environment-dotnet/action.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index fff4241..3228203 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -8,7 +8,7 @@ if [ "$GITHUB_REF_NAME" = 'main' ]; then elif [ "$ENV" = 'staging' ]; then ENVIRONMENT='uat' ENVIRONMENT_ELK='uat' - ELASTIC_APM_SERVER_URL='http://10.221.0.114:8200' + ELASTIC_APM_SERVER_URL='http://10.204.0.112:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" else ENVIRONMENT='dev' From e81b471fa63c5f5b66ff86762a3ce2893ac7517f Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Wed, 8 May 2024 18:42:57 -0300 Subject: [PATCH 10/55] removendo env --- environment-dotnet/action.sh | 2 +- environment-dotnet/action.yml | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index 3228203..fce6c20 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -5,7 +5,7 @@ if [ "$GITHUB_REF_NAME" = 'main' ]; then ENVIRONMENT_ELK='production' ELASTIC_APM_SERVER_URL='http://10.56.0.2:8200' JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/" -elif [ "$ENV" = 'staging' ]; then +elif [ "$GITHUB_REF_NAME" = 'staging' ]; then ENVIRONMENT='uat' ENVIRONMENT_ELK='uat' ELASTIC_APM_SERVER_URL='http://10.204.0.112:8200' diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index 19c1d6b..513c300 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -8,9 +8,6 @@ inputs: ref_name: required: true description: ref_name - environment: - required: true - description: environment project_id: required: true description: project_id From 741ee8b4f59897cfa4a7e8f3260c2a5533f0d5bb Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Thu, 9 May 2024 09:28:54 -0300 Subject: [PATCH 11/55] adicionar aspas e remover escapes --- environment-dotnet/action.sh | 34 +++++++++++++++++----------------- environment-dotnet/action.yml | 1 - 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index fce6c20..3667034 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -20,23 +20,23 @@ fi { echo "" if ! [ "$ENVIRONMENT" = "dev" ]; then - echo ELASTIC_APM_ENABLED: \'true\' + echo "ELASTIC_APM_ENABLED: 'true'" fi - echo JKS_ALTERNATIVE_HEADER_FORWARDED_FOR: \'X-Forwarded-For\' - 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\' - echo APPNAME: \'"$APPNAME"\' - echo JKS_USE_ELASTIC_APM: \'false\' - echo ELASTIC_APM_RECORDING: \'true\' - echo ELASTIC_APM_SERVICE_NAME: \'"$APPNAME"\' - echo ELASTIC_APM_ENVIRONMENT: \'$ENVIRONMENT_ELK\' - echo ELASTIC_APM_CAPTURE_BODY: \'all\' - echo ELASTIC_APM_CAPTURE_BODY_CONTENT_TYPES: \'*\' - echo ELASTIC_APM_CAPTURE_HEADERS: \'true\' - echo JKS_USE_APM: \'true\' - echo PLATFORM: \'Cloudrun\' + echo "JKS_ALTERNATIVE_HEADER_FORWARDED_FOR: 'X-Forwarded-For'" + 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'" + echo "APPNAME: '$APPNAME'" + echo "JKS_USE_ELASTIC_APM: 'false'" + echo "ELASTIC_APM_RECORDING: 'true'" + echo "ELASTIC_APM_SERVICE_NAME: '$APPNAME'" + echo "ELASTIC_APM_ENVIRONMENT: '$ENVIRONMENT_ELK'" + echo "ELASTIC_APM_CAPTURE_BODY: 'all'" + echo "ELASTIC_APM_CAPTURE_BODY_CONTENT_TYPES: '*'" + echo "ELASTIC_APM_CAPTURE_HEADERS: 'true'" + echo "JKS_USE_APM: 'true'" + echo "PLATFORM: 'Cloudrun'" } > tmpfile @@ -51,4 +51,4 @@ awk ' } } ' merged_temp.yaml > ./envs/env-$ENVIRONMENT.yaml -rm tmpfile merged_temp.yaml \ No newline at end of file +rm tmpfile merged_temp.yaml diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index 513c300..21ee44c 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -29,7 +29,6 @@ runs: run: ${{ github.action_path }}/action.sh env: GITHUB_REF_NAME: ${{ inputs.ref_name }} - ENV: ${{ inputs.environment }} APPNAME: ${{ inputs.app_name }} GOOGLE_PROJECTID: ${{ inputs.project_id}} MAX_INSTANCES: ${{ inputs.max_instances }} From eab16c65f0a3c8b6763b264a743606fe2f130915 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Thu, 9 May 2024 09:31:57 -0300 Subject: [PATCH 12/55] =?UTF-8?q?adicionar=20espa=C3=A7o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- environment-dotnet/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index 21ee44c..cf76980 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -33,4 +33,5 @@ runs: GOOGLE_PROJECTID: ${{ inputs.project_id}} MAX_INSTANCES: ${{ inputs.max_instances }} JKS_SAFE_IPS: ${{ inputs.safe_ips }} - REGION: ${{ inputs.gcp_region }} \ No newline at end of file + REGION: ${{ inputs.gcp_region }} + \ No newline at end of file From 8d6fef7693d53acca576e4ab612bc19979e44caf Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Thu, 9 May 2024 09:32:27 -0300 Subject: [PATCH 13/55] ajuste --- environment-dotnet/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index cf76980..a270168 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -34,4 +34,3 @@ runs: MAX_INSTANCES: ${{ inputs.max_instances }} JKS_SAFE_IPS: ${{ inputs.safe_ips }} REGION: ${{ inputs.gcp_region }} - \ No newline at end of file From 0133787f721fab50e40b54b119ea66f302396a7d Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Thu, 9 May 2024 10:34:31 -0300 Subject: [PATCH 14/55] trazer variaveis para o projeto --- environment-dotnet/action.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index 3667034..1f1ed06 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -2,17 +2,14 @@ if [ "$GITHUB_REF_NAME" = 'main' ]; then ENVIRONMENT='prd' - ENVIRONMENT_ELK='production' ELASTIC_APM_SERVER_URL='http://10.56.0.2:8200' JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/" elif [ "$GITHUB_REF_NAME" = 'staging' ]; then ENVIRONMENT='uat' - ENVIRONMENT_ELK='uat' ELASTIC_APM_SERVER_URL='http://10.204.0.112:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" else ENVIRONMENT='dev' - ENVIRONMENT_ELK='develop' ELASTIC_APM_SERVER_URL='http://10.221.0.114:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" fi @@ -21,21 +18,12 @@ fi echo "" if ! [ "$ENVIRONMENT" = "dev" ]; then echo "ELASTIC_APM_ENABLED: 'true'" - fi - echo "JKS_ALTERNATIVE_HEADER_FORWARDED_FOR: 'X-Forwarded-For'" + 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'" - echo "APPNAME: '$APPNAME'" - echo "JKS_USE_ELASTIC_APM: 'false'" - echo "ELASTIC_APM_RECORDING: 'true'" - echo "ELASTIC_APM_SERVICE_NAME: '$APPNAME'" - echo "ELASTIC_APM_ENVIRONMENT: '$ENVIRONMENT_ELK'" - echo "ELASTIC_APM_CAPTURE_BODY: 'all'" - echo "ELASTIC_APM_CAPTURE_BODY_CONTENT_TYPES: '*'" - echo "ELASTIC_APM_CAPTURE_HEADERS: 'true'" - echo "JKS_USE_APM: 'true'" + echo "PLATFORM: 'Cloudrun'" } > tmpfile From 56f594077172240b07390b8dbb762ccc14484c94 Mon Sep 17 00:00:00 2001 From: Gabriel Vieira Lavor Date: Thu, 9 May 2024 10:40:35 -0300 Subject: [PATCH 15/55] =?UTF-8?q?remover=20entradas=20n=C3=A3o=20usadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- environment-dotnet/action.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/environment-dotnet/action.yml b/environment-dotnet/action.yml index a270168..0f01772 100644 --- a/environment-dotnet/action.yml +++ b/environment-dotnet/action.yml @@ -2,25 +2,15 @@ name: Create Env description: Create Env inputs: - app_name: - required: true - description: app_name ref_name: required: true description: ref_name project_id: required: true description: project_id - max_instances: - required: true - description: max_instances safe_ips: required: true description: safe_ips - gcp_region: - required: true - description: gcp_region - runs: using: composite steps: @@ -29,8 +19,5 @@ runs: run: ${{ github.action_path }}/action.sh env: GITHUB_REF_NAME: ${{ inputs.ref_name }} - APPNAME: ${{ inputs.app_name }} GOOGLE_PROJECTID: ${{ inputs.project_id}} - MAX_INSTANCES: ${{ inputs.max_instances }} JKS_SAFE_IPS: ${{ inputs.safe_ips }} - REGION: ${{ inputs.gcp_region }} From b164ef83c548e62aac0eb11813d5a87bfe0080c8 Mon Sep 17 00:00:00 2001 From: Gabriel Lavor Date: Thu, 13 Jun 2024 14:33:17 -0300 Subject: [PATCH 16/55] add env qa (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * adicionar action para definir as variáveis de ambiente --------- Co-authored-by: Gabriel Vieira Lavor --- environment-dotnet/action.sh | 15 ++++++++------- environment-test-dotnet/action.sh | 13 +++++++++++++ environment-test-dotnet/action.yml | 9 +++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100755 environment-test-dotnet/action.sh create mode 100644 environment-test-dotnet/action.yml diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index 1f1ed06..8afcd8c 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -2,15 +2,19 @@ if [ "$GITHUB_REF_NAME" = 'main' ]; then ENVIRONMENT='prd' - ELASTIC_APM_SERVER_URL='http://10.56.0.2:8200' + ELASTIC_APM_SERVER_URL='http://elastic.noverde.com:8200' JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/" elif [ "$GITHUB_REF_NAME" = 'staging' ]; then ENVIRONMENT='uat' - ELASTIC_APM_SERVER_URL='http://10.204.0.112:8200' + ELASTIC_APM_SERVER_URL='http://elastic.uat.noverde.com:8200' + JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" +elif [ "$GITHUB_REF_NAME" = 'qa' ]; then + ENVIRONMENT='uat' + ELASTIC_APM_SERVER_URL='http://elastic.uat.noverde.com:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" else ENVIRONMENT='dev' - ELASTIC_APM_SERVER_URL='http://10.221.0.114:8200' + ELASTIC_APM_SERVER_URL='http://elastic.dev.noverde.com:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" fi @@ -18,14 +22,11 @@ fi echo "" if ! [ "$ENVIRONMENT" = "dev" ]; then echo "ELASTIC_APM_ENABLED: 'true'" - fi + 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'" - - echo "PLATFORM: 'Cloudrun'" - } > tmpfile cat ./envs/env-$ENVIRONMENT.yaml tmpfile > merged_temp.yaml 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 From 15fa2fd92aca24d7683c7acaf11dbc65573e5615 Mon Sep 17 00:00:00 2001 From: JuanOioli Date: Tue, 6 May 2025 15:01:34 -0300 Subject: [PATCH 17/55] Feat: modifying elk url get by workflow input --- environment-dotnet/action.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/environment-dotnet/action.sh b/environment-dotnet/action.sh index 8afcd8c..414919e 100755 --- a/environment-dotnet/action.sh +++ b/environment-dotnet/action.sh @@ -2,19 +2,15 @@ if [ "$GITHUB_REF_NAME" = 'main' ]; then ENVIRONMENT='prd' - ELASTIC_APM_SERVER_URL='http://elastic.noverde.com:8200' JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/" elif [ "$GITHUB_REF_NAME" = 'staging' ]; then ENVIRONMENT='uat' - ELASTIC_APM_SERVER_URL='http://elastic.uat.noverde.com:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" elif [ "$GITHUB_REF_NAME" = 'qa' ]; then ENVIRONMENT='uat' - ELASTIC_APM_SERVER_URL='http://elastic.uat.noverde.com:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" else ENVIRONMENT='dev' - ELASTIC_APM_SERVER_URL='http://elastic.dev.noverde.com:8200' JWT_JWKS_PATH="https://uat.dotznext.com/accounts/api/default/" fi From 601199433b3cac60a65e94272e949dababbb1da6 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 11:49:41 -0300 Subject: [PATCH 18/55] feat: add sonarqube --- sonarqube-python/action.yml | 100 ++++++++++++++++++++ sonarqube-python/coverage-calc.sh | 7 ++ sonarqube-python/quality-gates-sonarqube.sh | 41 ++++++++ sonarqube-python/sonarqube-status.sh | 14 +++ 4 files changed, 162 insertions(+) create mode 100644 sonarqube-python/action.yml create mode 100644 sonarqube-python/coverage-calc.sh create mode 100644 sonarqube-python/quality-gates-sonarqube.sh create mode 100644 sonarqube-python/sonarqube-status.sh diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml new file mode 100644 index 0000000..99ddfa4 --- /dev/null +++ b/sonarqube-python/action.yml @@ -0,0 +1,100 @@ +name: 'Sonarqube Python Scanner' +description: 'Quality Gate Sonarqube for Python projects' + +inputs: + sonar-verbose: + required: false + type: boolean + default: false + sonar-sources: + required: false + type: string + default: "src" + sonar-sources-tests: + required: false + type: string + default: "tests" + sonar-test-inclusions: + required: false + type: string + default: "**/test_*.py,**/*_test.py,**/__pycache__/**,**/__init__.py" + sonar-report-paths: + required: false + type: string + default: "coverage.xml" + sonar-source-encoding: + required: false + type: string + default: "UTF-8" + sonar-exclusions: + required: false + type: string + default: "**/__pycache__/**,**/*.pyc,**/migrations/**, + **/fixtures/**,**/.venv/**,**/.git/**,**/.vscode/**,**/*.html,**/htmlcov/**,coverage.xml" + sonar-lang: + required: false + type: string + default: "python" + sonar-lang-version: + required: false + type: string + sonar-token: + type: string + sonar-host-url: + type: string + sonar-api-token: + type: string + +runs: + using: composite + steps: + - name: Push to RubyGems + shell: bash + run: ${{ github.action_path }}/action.sh + env: + RUBYGEMS_API_KEY: ${{ inputs.rubygems_api_key }} + - name: SonarQube Scan + if: | + github.base_ref == 'develop' && + inputs.sonar-enable == true && + inputs.sonar-lang == 'python' + uses: sonarsource/sonarqube-scan-action@v5.2.0 + continue-on-error: true + with: + args: > + -Dsonar.projectKey=${{ github.event.repository.name }} + -Dsonar.sources=${{ inputs.sonar-sources }} + -Dsonar.tests=${{ inputs.sonar-sources-tests }} + -Dsonar.test.inclusions=${{inputs.sonar-test-inclusions }} + -Dsonar.exclusions=${{ inputs.sonar-exclusions }} + -Dsonar.python.version=${{ inputs.sonar-lang-version }} + -Dsonar.python.coverage.reportPaths=${{ inputs.sonar-report-paths }} + -Dsonar.verbose=${{ inputs.sonar-verbose }} + -Dsonar.sourceEncoding=${{ inputs.sonar-source-encoding }} + env: + SONAR_TOKEN: ${{ inputs.sonar-token }} + SONAR_HOST_URL: ${{ secrets.sonar-host-url }} + + - name: Check SonarQube Quality Gate Status + id: sonarqube-status + if: github.base_ref == 'develop' && inputs.sonar-enable == true + continue-on-error: true + run: ${{ github.action_path }}/sonarqube-status.sh + env: + SONAR_TOKEN: ${{ inputs.sonar-api-token }} + SONAR_HOST_URL: ${{ secrets.sonar-host-url }} + + - name: Get Coverage + id: coverage-calc + if: steps.sonarqube-status.outputs.status == 'OK' + continue-on-error: true + run: ${{ github.action_path }}/coverage-calc.sh + + - name: Update Quality Gates Sonarqube + id: quality-gates-sonarqube + if: steps.sonarqube-status.outputs.status == 'OK' + continue-on-error: true + run: ${{ github.action_path }}/quality-gates-sonarqube.sh + env: + SONAR_TOKEN: ${{ inputs.sonar-api-token }} + SONAR_HOST_URL: ${{ secrets.sonar-host-url }} diff --git a/sonarqube-python/coverage-calc.sh b/sonarqube-python/coverage-calc.sh new file mode 100644 index 0000000..b94fc77 --- /dev/null +++ b/sonarqube-python/coverage-calc.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +COVERAGE=$(python -c "import xml.etree.ElementTree as ET; \ +print(float(ET.parse('coverage.xml').getroot().attrib['line-rate']) * 100)") + +echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT +echo "legacy_coverage=$COVERAGE" >> $GITHUB_OUTPUT diff --git a/sonarqube-python/quality-gates-sonarqube.sh b/sonarqube-python/quality-gates-sonarqube.sh new file mode 100644 index 0000000..badec34 --- /dev/null +++ b/sonarqube-python/quality-gates-sonarqube.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +PROJECT_RESPONSE=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/get_by_project?project=${{ github.event.repository.name }}") + +QUALITY_GATE_NAME=$(echo "$PROJECT_RESPONSE" | jq -r '.qualityGate.name') +QUALITY_GATE_NAME=$(echo "$QUALITY_GATE_NAME" | jq -sRr @uri) + +echo "Quality Gate Name: $QUALITY_GATE_NAME" + +GATE_RESPONSE=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/show?name=$QUALITY_GATE_NAME") + +NEW_COV_CONDITION_ID=$(echo "$GATE_RESPONSE" | jq -r '.conditions[] | select(.metric=="coverage") | .id') +CURRENT_NEW_COV=$(echo "$GATE_RESPONSE" | jq -r '.conditions[] | select(.metric=="coverage") | .error') +LEGACY_COV_NUM=${{ steps.coverage-calc.outputs.coverage }} + +if [ -n "$NEW_COV_CONDITION_ID" ]; then + CURRENT_NEW_COV_NUM=$(echo "$CURRENT_NEW_COV" | sed 's/[^0-9.]*//g') + + if (( $(echo "$LEGACY_COV_NUM > $CURRENT_NEW_COV_NUM" | bc -l) )); then + if (( $(echo "$LEGACY_COV_NUM > 80" | bc -l) )); then + echo "Legacy coverage ($LEGACY_COV_NUM%) > 80%, updating new_coverage threshold to 80%" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/update_condition" \ + -d "id=$NEW_COV_CONDITION_ID&metric=new_coverage&op=LT&error=80" + else + echo "Updating new_coverage threshold from $CURRENT_NEW_COV to $LEGACY_COV_NUM%" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/update_condition" \ + -d "id=$NEW_COV_CONDITION_ID&metric=new_coverage&op=LT&error=$LEGACY_COV_NUM" + fi + else + echo "Legacy coverage ($LEGACY_COV_NUM%) not greater than current new_coverage ($CURRENT_NEW_COV), keeping existing configuration" + fi +else + echo "Criando nova condição para new_coverage" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/create_condition" \ + -d "gateName=$QUALITY_GATE_NAME&metric=new_coverage&op=LT&error=$LEGACY_COV_NUM" +fi diff --git a/sonarqube-python/sonarqube-status.sh b/sonarqube-python/sonarqube-status.sh new file mode 100644 index 0000000..afdb152 --- /dev/null +++ b/sonarqube-python/sonarqube-status.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +sleep 10 +SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=${{ github.event.repository.name }}") + +STATUS=$(echo "$SONAR_STATUS" | jq -r '.projectStatus.status') + +echo "status=$STATUS" >> $GITHUB_OUTPUT +echo "sonarqube ${{ github.event.repository.name }} status: $STATUS" +if [ "$STATUS" = "ERROR" ]; then + echo "Quality Gate falhou!" + exit 1 +fi From f3c62fb80b57685d330aa6c0f13ff96a44003d0a Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:00:12 -0300 Subject: [PATCH 19/55] feat: add sonarqube --- sonarqube-python/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index 99ddfa4..cd7144f 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -73,7 +73,7 @@ runs: -Dsonar.sourceEncoding=${{ inputs.sonar-source-encoding }} env: SONAR_TOKEN: ${{ inputs.sonar-token }} - SONAR_HOST_URL: ${{ secrets.sonar-host-url }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} - name: Check SonarQube Quality Gate Status id: sonarqube-status @@ -82,7 +82,7 @@ runs: run: ${{ github.action_path }}/sonarqube-status.sh env: SONAR_TOKEN: ${{ inputs.sonar-api-token }} - SONAR_HOST_URL: ${{ secrets.sonar-host-url }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} - name: Get Coverage id: coverage-calc @@ -97,4 +97,4 @@ runs: run: ${{ github.action_path }}/quality-gates-sonarqube.sh env: SONAR_TOKEN: ${{ inputs.sonar-api-token }} - SONAR_HOST_URL: ${{ secrets.sonar-host-url }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} From ecb441bde09372fe5587fe9c53d7e1649f00d8c9 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:02:21 -0300 Subject: [PATCH 20/55] feat: add sonarqube --- sonarqube-python/action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index cd7144f..a14726d 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -77,6 +77,7 @@ runs: - name: Check SonarQube Quality Gate Status id: sonarqube-status + shell: bash if: github.base_ref == 'develop' && inputs.sonar-enable == true continue-on-error: true run: ${{ github.action_path }}/sonarqube-status.sh @@ -85,12 +86,14 @@ runs: SONAR_HOST_URL: ${{ inputs.sonar-host-url }} - name: Get Coverage + shell: bash id: coverage-calc if: steps.sonarqube-status.outputs.status == 'OK' continue-on-error: true run: ${{ github.action_path }}/coverage-calc.sh - name: Update Quality Gates Sonarqube + shell: bash id: quality-gates-sonarqube if: steps.sonarqube-status.outputs.status == 'OK' continue-on-error: true From 7ad944df5d897141ac684cb722fb5f266cd8304b Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:08:37 -0300 Subject: [PATCH 21/55] feat: add sonarqube --- sonarqube-python/action.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index a14726d..4b01396 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -31,13 +31,10 @@ inputs: type: string default: "**/__pycache__/**,**/*.pyc,**/migrations/**, **/fixtures/**,**/.venv/**,**/.git/**,**/.vscode/**,**/*.html,**/htmlcov/**,coverage.xml" - sonar-lang: - required: false - type: string - default: "python" sonar-lang-version: required: false type: string + default: "3.11" sonar-token: type: string sonar-host-url: @@ -48,16 +45,7 @@ inputs: runs: using: composite steps: - - name: Push to RubyGems - shell: bash - run: ${{ github.action_path }}/action.sh - env: - RUBYGEMS_API_KEY: ${{ inputs.rubygems_api_key }} - name: SonarQube Scan - if: | - github.base_ref == 'develop' && - inputs.sonar-enable == true && - inputs.sonar-lang == 'python' uses: sonarsource/sonarqube-scan-action@v5.2.0 continue-on-error: true with: @@ -78,7 +66,6 @@ runs: - name: Check SonarQube Quality Gate Status id: sonarqube-status shell: bash - if: github.base_ref == 'develop' && inputs.sonar-enable == true continue-on-error: true run: ${{ github.action_path }}/sonarqube-status.sh env: From d17c006a7209b54bd6a736b854cccc88d92e70b7 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:12:31 -0300 Subject: [PATCH 22/55] feat: add sonarqube --- sonarqube-python/action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index 4b01396..f80ff09 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -35,11 +35,14 @@ inputs: required: false type: string default: "3.11" - sonar-token: - type: string sonar-host-url: + required: true type: string sonar-api-token: + required: true + type: string + sonar-token: + required: true type: string runs: From c153bfa5693d5f0063b31f27a32cede16e8ce840 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:19:35 -0300 Subject: [PATCH 23/55] feat: add sonarqube --- sonarqube-python/coverage-calc.sh | 0 sonarqube-python/quality-gates-sonarqube.sh | 0 sonarqube-python/sonarqube-status.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 sonarqube-python/coverage-calc.sh mode change 100644 => 100755 sonarqube-python/quality-gates-sonarqube.sh mode change 100644 => 100755 sonarqube-python/sonarqube-status.sh diff --git a/sonarqube-python/coverage-calc.sh b/sonarqube-python/coverage-calc.sh old mode 100644 new mode 100755 diff --git a/sonarqube-python/quality-gates-sonarqube.sh b/sonarqube-python/quality-gates-sonarqube.sh old mode 100644 new mode 100755 diff --git a/sonarqube-python/sonarqube-status.sh b/sonarqube-python/sonarqube-status.sh old mode 100644 new mode 100755 From 6f18d7edb2a7c28fdc251a2802f65b8db8ad5a4f Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:23:06 -0300 Subject: [PATCH 24/55] feat: add sonarqube --- sonarqube-python/action.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index f80ff09..7e8cda5 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -44,6 +44,9 @@ inputs: sonar-token: required: true type: string + sonar-project-key: + required: true + type: string runs: using: composite @@ -53,7 +56,7 @@ runs: continue-on-error: true with: args: > - -Dsonar.projectKey=${{ github.event.repository.name }} + -Dsonar.projectKey=${{ inputs.sonar-project-key }} -Dsonar.sources=${{ inputs.sonar-sources }} -Dsonar.tests=${{ inputs.sonar-sources-tests }} -Dsonar.test.inclusions=${{inputs.sonar-test-inclusions }} From 2e9edaf0f2719408b440c6161e49a27e496c3a83 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:30:56 -0300 Subject: [PATCH 25/55] feat: add sonarqube --- sonarqube-python/action.yml | 2 ++ sonarqube-python/quality-gates-sonarqube.sh | 2 +- sonarqube-python/sonarqube-status.sh | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index 7e8cda5..e8145f8 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -75,6 +75,7 @@ runs: continue-on-error: true run: ${{ github.action_path }}/sonarqube-status.sh env: + SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} SONAR_TOKEN: ${{ inputs.sonar-api-token }} SONAR_HOST_URL: ${{ inputs.sonar-host-url }} @@ -92,5 +93,6 @@ runs: continue-on-error: true run: ${{ github.action_path }}/quality-gates-sonarqube.sh env: + SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} SONAR_TOKEN: ${{ inputs.sonar-api-token }} SONAR_HOST_URL: ${{ inputs.sonar-host-url }} diff --git a/sonarqube-python/quality-gates-sonarqube.sh b/sonarqube-python/quality-gates-sonarqube.sh index badec34..dcd4751 100755 --- a/sonarqube-python/quality-gates-sonarqube.sh +++ b/sonarqube-python/quality-gates-sonarqube.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash PROJECT_RESPONSE=$(curl -s -u "$SONAR_TOKEN:" \ -"$SONAR_HOST_URL/api/qualitygates/get_by_project?project=${{ github.event.repository.name }}") +"$SONAR_HOST_URL/api/qualitygates/get_by_project?project=$SONAR_PROJECT_KEY") QUALITY_GATE_NAME=$(echo "$PROJECT_RESPONSE" | jq -r '.qualityGate.name') QUALITY_GATE_NAME=$(echo "$QUALITY_GATE_NAME" | jq -sRr @uri) diff --git a/sonarqube-python/sonarqube-status.sh b/sonarqube-python/sonarqube-status.sh index afdb152..53703b0 100755 --- a/sonarqube-python/sonarqube-status.sh +++ b/sonarqube-python/sonarqube-status.sh @@ -2,12 +2,12 @@ sleep 10 SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ -"$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=${{ github.event.repository.name }}") +"$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$SONAR_PROJECT_KEY") STATUS=$(echo "$SONAR_STATUS" | jq -r '.projectStatus.status') echo "status=$STATUS" >> $GITHUB_OUTPUT -echo "sonarqube ${{ github.event.repository.name }} status: $STATUS" +echo "sonarqube $SONAR_PROJECT_KEY status: $STATUS" if [ "$STATUS" = "ERROR" ]; then echo "Quality Gate falhou!" exit 1 From fe11bedb0a35e145dffa6f185c2282c2a3ccf394 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:40:02 -0300 Subject: [PATCH 26/55] feat: add sonarqube --- sonarqube-python/sonarqube-status.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sonarqube-python/sonarqube-status.sh b/sonarqube-python/sonarqube-status.sh index 53703b0..16bf123 100755 --- a/sonarqube-python/sonarqube-status.sh +++ b/sonarqube-python/sonarqube-status.sh @@ -4,11 +4,19 @@ sleep 10 SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ "$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$SONAR_PROJECT_KEY") +# Extract overall status STATUS=$(echo "$SONAR_STATUS" | jq -r '.projectStatus.status') -echo "status=$STATUS" >> $GITHUB_OUTPUT -echo "sonarqube $SONAR_PROJECT_KEY status: $STATUS" -if [ "$STATUS" = "ERROR" ]; then - echo "Quality Gate falhou!" +# Process failing conditions +echo "SonarQube Quality Gate Status: $STATUS" +if [ "$STATUS" != "OK" ]; then + echo "=== Failing Conditions ===" + echo "$SONAR_STATUS" | jq -r '.projectStatus.conditions[] | select(.status != "OK") | "Metric: \(.metricKey) | Threshold: \(.errorThreshold) | Actual: \(.actualValue)"' + + echo "status=$STATUS" >> $GITHUB_OUTPUT + echo "::error::Quality Gate failed with status: $STATUS" exit 1 fi + +echo "status=$STATUS" >> $GITHUB_OUTPUT +echo "Quality Gate passed successfully!" From b5f20d7dae9d779cbae497f2d998847964150c09 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:41:23 -0300 Subject: [PATCH 27/55] feat: add sonarqube --- sonarqube-python/sonarqube-status.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarqube-python/sonarqube-status.sh b/sonarqube-python/sonarqube-status.sh index 16bf123..e98a3a6 100755 --- a/sonarqube-python/sonarqube-status.sh +++ b/sonarqube-python/sonarqube-status.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -sleep 10 +sleep 5 SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ "$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$SONAR_PROJECT_KEY") From da59404ad940024a5a3bb649193e9321bb780ea3 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:49:16 -0300 Subject: [PATCH 28/55] feat: add sonarqube --- sonarqube-python/action.yml | 50 ++++++++++++++-------------- sonarqube-python/sonarqube-status.sh | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index e8145f8..e514e40 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -69,30 +69,30 @@ runs: SONAR_TOKEN: ${{ inputs.sonar-token }} SONAR_HOST_URL: ${{ inputs.sonar-host-url }} - - name: Check SonarQube Quality Gate Status - id: sonarqube-status - shell: bash - continue-on-error: true - run: ${{ github.action_path }}/sonarqube-status.sh - env: - SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} - SONAR_TOKEN: ${{ inputs.sonar-api-token }} - SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + # - name: Check SonarQube Quality Gate Status + # id: sonarqube-status + # shell: bash + # continue-on-error: true + # run: ${{ github.action_path }}/sonarqube-status.sh + # env: + # SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} + # SONAR_TOKEN: ${{ inputs.sonar-api-token }} + # SONAR_HOST_URL: ${{ inputs.sonar-host-url }} - - name: Get Coverage - shell: bash - id: coverage-calc - if: steps.sonarqube-status.outputs.status == 'OK' - continue-on-error: true - run: ${{ github.action_path }}/coverage-calc.sh + # - name: Get Coverage + # shell: bash + # id: coverage-calc + # if: steps.sonarqube-status.outputs.status == 'OK' + # continue-on-error: true + # run: ${{ github.action_path }}/coverage-calc.sh - - name: Update Quality Gates Sonarqube - shell: bash - id: quality-gates-sonarqube - if: steps.sonarqube-status.outputs.status == 'OK' - continue-on-error: true - run: ${{ github.action_path }}/quality-gates-sonarqube.sh - env: - SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} - SONAR_TOKEN: ${{ inputs.sonar-api-token }} - SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + # - name: Update Quality Gates Sonarqube + # shell: bash + # id: quality-gates-sonarqube + # if: steps.sonarqube-status.outputs.status == 'OK' + # continue-on-error: true + # run: ${{ github.action_path }}/quality-gates-sonarqube.sh + # env: + # SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} + # SONAR_TOKEN: ${{ inputs.sonar-api-token }} + # SONAR_HOST_URL: ${{ inputs.sonar-host-url }} diff --git a/sonarqube-python/sonarqube-status.sh b/sonarqube-python/sonarqube-status.sh index e98a3a6..16bf123 100755 --- a/sonarqube-python/sonarqube-status.sh +++ b/sonarqube-python/sonarqube-status.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -sleep 5 +sleep 10 SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ "$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$SONAR_PROJECT_KEY") From 9127dbfffe5d8638cb7149b41cf72d04664d8242 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 12:56:13 -0300 Subject: [PATCH 29/55] feat: add sonarqube --- sonarqube-python/action.yml | 53 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index e514e40..9309d35 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -29,8 +29,7 @@ inputs: sonar-exclusions: required: false type: string - default: "**/__pycache__/**,**/*.pyc,**/migrations/**, - **/fixtures/**,**/.venv/**,**/.git/**,**/.vscode/**,**/*.html,**/htmlcov/**,coverage.xml" + default: "**/__pycache__/**,**/*.pyc,**/migrations/**,**/fixtures/**,**/.venv/**,**/.git/**,**/.vscode/**,**/*.html,**/htmlcov/**,coverage.xml" sonar-lang-version: required: false type: string @@ -69,30 +68,30 @@ runs: SONAR_TOKEN: ${{ inputs.sonar-token }} SONAR_HOST_URL: ${{ inputs.sonar-host-url }} - # - name: Check SonarQube Quality Gate Status - # id: sonarqube-status - # shell: bash - # continue-on-error: true - # run: ${{ github.action_path }}/sonarqube-status.sh - # env: - # SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} - # SONAR_TOKEN: ${{ inputs.sonar-api-token }} - # SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + - name: Check SonarQube Quality Gate Status + id: sonarqube-status + shell: bash + continue-on-error: true + run: ${{ github.action_path }}/sonarqube-status.sh + env: + SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} + SONAR_TOKEN: ${{ inputs.sonar-api-token }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} - # - name: Get Coverage - # shell: bash - # id: coverage-calc - # if: steps.sonarqube-status.outputs.status == 'OK' - # continue-on-error: true - # run: ${{ github.action_path }}/coverage-calc.sh + - name: Get Coverage + shell: bash + id: coverage-calc + if: steps.sonarqube-status.outputs.status == 'OK' + continue-on-error: true + run: ${{ github.action_path }}/coverage-calc.sh - # - name: Update Quality Gates Sonarqube - # shell: bash - # id: quality-gates-sonarqube - # if: steps.sonarqube-status.outputs.status == 'OK' - # continue-on-error: true - # run: ${{ github.action_path }}/quality-gates-sonarqube.sh - # env: - # SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} - # SONAR_TOKEN: ${{ inputs.sonar-api-token }} - # SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + - name: Update Quality Gates Sonarqube + shell: bash + id: quality-gates-sonarqube + if: steps.sonarqube-status.outputs.status == 'OK' + continue-on-error: true + run: ${{ github.action_path }}/quality-gates-sonarqube.sh + env: + SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} + SONAR_TOKEN: ${{ inputs.sonar-api-token }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} From 0751bb5d56617d6e8d882fcca00d17c1fbf86328 Mon Sep 17 00:00:00 2001 From: dev morais Date: Thu, 26 Jun 2025 13:05:21 -0300 Subject: [PATCH 30/55] feat: add sonarqube --- sonarqube-python/action.yml | 1 + sonarqube-python/quality-gates-sonarqube.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index 9309d35..c7a687a 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -95,3 +95,4 @@ runs: SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} SONAR_TOKEN: ${{ inputs.sonar-api-token }} SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + LEGACY_COV_NUM: ${{ steps.coverage-calc.outputs.coverage }} diff --git a/sonarqube-python/quality-gates-sonarqube.sh b/sonarqube-python/quality-gates-sonarqube.sh index dcd4751..ece3e2a 100755 --- a/sonarqube-python/quality-gates-sonarqube.sh +++ b/sonarqube-python/quality-gates-sonarqube.sh @@ -13,7 +13,6 @@ GATE_RESPONSE=$(curl -s -u "$SONAR_TOKEN:" \ NEW_COV_CONDITION_ID=$(echo "$GATE_RESPONSE" | jq -r '.conditions[] | select(.metric=="coverage") | .id') CURRENT_NEW_COV=$(echo "$GATE_RESPONSE" | jq -r '.conditions[] | select(.metric=="coverage") | .error') -LEGACY_COV_NUM=${{ steps.coverage-calc.outputs.coverage }} if [ -n "$NEW_COV_CONDITION_ID" ]; then CURRENT_NEW_COV_NUM=$(echo "$CURRENT_NEW_COV" | sed 's/[^0-9.]*//g') From fe445ed35706be0a451e8f0d102ffd4df02b5c81 Mon Sep 17 00:00:00 2001 From: Diego Morais <104941487+diego-dm-morais@users.noreply.github.com> Date: Thu, 26 Jun 2025 15:13:32 -0300 Subject: [PATCH 31/55] feat: add sonarqube (#5) --- sonarqube-python/quality-gates-sonarqube.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sonarqube-python/quality-gates-sonarqube.sh b/sonarqube-python/quality-gates-sonarqube.sh index ece3e2a..3cb5c5f 100755 --- a/sonarqube-python/quality-gates-sonarqube.sh +++ b/sonarqube-python/quality-gates-sonarqube.sh @@ -19,22 +19,22 @@ if [ -n "$NEW_COV_CONDITION_ID" ]; then if (( $(echo "$LEGACY_COV_NUM > $CURRENT_NEW_COV_NUM" | bc -l) )); then if (( $(echo "$LEGACY_COV_NUM > 80" | bc -l) )); then - echo "Legacy coverage ($LEGACY_COV_NUM%) > 80%, updating new_coverage threshold to 80%" + echo "Legacy coverage ($LEGACY_COV_NUM%) > 80%, updating coverage threshold to 80%" curl -u "$SONAR_TOKEN:" -X POST \ "$SONAR_HOST_URL/api/qualitygates/update_condition" \ - -d "id=$NEW_COV_CONDITION_ID&metric=new_coverage&op=LT&error=80" + -d "id=$NEW_COV_CONDITION_ID&metric=coverage&op=LT&error=80" else - echo "Updating new_coverage threshold from $CURRENT_NEW_COV to $LEGACY_COV_NUM%" + echo "Updating coverage threshold from $CURRENT_NEW_COV to $LEGACY_COV_NUM%" curl -u "$SONAR_TOKEN:" -X POST \ "$SONAR_HOST_URL/api/qualitygates/update_condition" \ - -d "id=$NEW_COV_CONDITION_ID&metric=new_coverage&op=LT&error=$LEGACY_COV_NUM" + -d "id=$NEW_COV_CONDITION_ID&metric=coverage&op=LT&error=$LEGACY_COV_NUM" fi else - echo "Legacy coverage ($LEGACY_COV_NUM%) not greater than current new_coverage ($CURRENT_NEW_COV), keeping existing configuration" + echo "Legacy coverage ($LEGACY_COV_NUM%) not greater than current coverage ($CURRENT_NEW_COV), keeping existing configuration" fi else - echo "Criando nova condição para new_coverage" + echo "Criando nova condição para coverage" curl -u "$SONAR_TOKEN:" -X POST \ "$SONAR_HOST_URL/api/qualitygates/create_condition" \ - -d "gateName=$QUALITY_GATE_NAME&metric=new_coverage&op=LT&error=$LEGACY_COV_NUM" + -d "gateName=$QUALITY_GATE_NAME&metric=coverage&op=LT&error=$LEGACY_COV_NUM" fi From 39e675c2ce080e2ef9a1592c1b460893c526f022 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Thu, 26 Jun 2025 16:52:40 -0300 Subject: [PATCH 32/55] First commit to test --- gmud-creator/action.yml | 209 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 gmud-creator/action.yml diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml new file mode 100644 index 0000000..f7196c2 --- /dev/null +++ b/gmud-creator/action.yml @@ -0,0 +1,209 @@ +name: "Gmud Creator Action" +description: "Create a Gmud on GLPI" + +inputs: + glpi_api_url: + description: "The base URL of the GLPI API" + required: true + glpi_app_token: + description: "The application token for GLPI" + required: true + glpi_user_token: + description: "The user token for GLPI" + required: true + create_gmud: + description: "Flag to determine if GMUD should be created" + required: true + default: "false" + +runs: + using: "composite" + steps: + - name: Validate GLPI_API_URL format + shell: bash + if: ${{ inputs.create_gmud == 'true' }} + run: | + if [[ ! "$GLPI_API_URL" =~ ^https?:// ]]; then + echo "Error: GLPI_API_URL does not start with http:// or https://" + exit 1 + fi + echo "GLPI_API_URL format is valid" + env: + GLPI_API_URL: ${{ inputs.glpi_api_url }} + + - name: Extract PR Data + if: ${{ inputs.create_gmud == 'true' }} + id: extract-data + uses: actions/github-script@v6 + with: + script: | + const prBody = context.payload.pull_request.body; + const extractSection = (title) => { + const regex = new RegExp(`### ${title}[\\s\\S]*?\\n([\\s\\S]*?)(?=###|$)`); + const match = prBody.match(regex); + return match + ? match[1] + .trim() + .replace(/^- \[.\]|\*|^[\[\]]|[\[\]]$|\[|\]/g, '') + .trim() + : ''; + }; + + function extractResponsible(field) { + const regex = new RegExp(`\\*\\*${field}:\\*\\*\\s*\\[(@?[\\w\\s.-]+)\\]`, 'i'); + const match = text.match(regex); + return (match || [])[1] || 'Não especificado'; + }; + + const changeType = + /-\s\[x\]\s\*\*Imediata\*\*/i.test(prBody) ? 'Imediata' : + /-\s\[x\]\s\*\*Não Programada\*\*/i.test(prBody) ? 'Não Programada' : + /-\s\[x\]\s\*\*Programada\*\*/i.test(prBody) ? 'Programada' : ''; + + + const service = extractSection('Serviço Afetado'); + const summary = extractSection('Descrição Resumida'); + const contxt = extractSection('Contexto'); + const problem = extractSection('Problema') || 'N/A'; + const change = extractSection('Mudança Proposta'); + const impact = extractSection('Descrição de impacto'); + const task_link = extractSection('Link da Task'); + + const dev = extractResponsible('Dev'); + const tl = extractResponsible('TL'); + const team = extractResponsible('Team'); + const approver = extractSection('Aprovador') || 'Não especificado'; + + // Output para os próximos passos + core.setOutput('change_type', changeType); + core.setOutput('service', service); + core.setOutput('summary', summary); + core.setOutput('context', contxt); + core.setOutput('problem', problem); + core.setOutput('change', change); + core.setOutput('dev', dev); + core.setOutput('tl', tl); + core.setOutput('team', team); + core.setOutput('approver', approver); + core.setOutput('impact', impact); + core.setOutput('task_link', task_link); + core.setOutput('pr_url', context.payload.pull_request.html_url); + + - name: Create GMUD via API + if: ${{ inputs.create_gmud == 'true' }} + shell: bash + env: + GLPI_API_URL: ${{ inputs.glpi_api_url }} + GLPI_APP_TOKEN: ${{ inputs.glpi_app_token }} + GLPI_USER_TOKEN: ${{ inputs.glpi_user_token }} + run: | + echo "Initializing GLPI session at \$GLPI_API_URL/initSession" + SESSION_RESPONSE=$(curl -s -w "%{http_code}" --max-time 10 -X GET \ + -H "App-Token: $GLPI_APP_TOKEN" \ + -H "Authorization: user_token $GLPI_USER_TOKEN" \ + -H "Content-Type: application/json" \ + "$GLPI_API_URL/initSession" -o session.json 2> session_error.log || echo "Curl failed with exit code $?") + + SESSION_STATUS=${SESSION_RESPONSE##* } + echo "Session HTTP Status: $SESSION_STATUS" + + if [ -s session_error.log ]; then + echo "Session init error details:" + cat session_error.log + fi + + if [ ! -f session.json ]; then + echo "Error: session.json not created" + exit 1 + fi + + SESSION_TOKEN=$(jq -r '.session_token' session.json 2>/dev/null) + if [ -z "$SESSION_TOKEN" ]; then + echo "Error: Failed to extract session_token from session.json" + cat session.json + exit 1 + fi + + GMUD_CONTENT=$(cat <Contexto:

+

${{ steps.extract-data.outputs.context }}

+
+

Problema:

+

${{ steps.extract-data.outputs.problem }}

+
+

Mudança:

+

${{ steps.extract-data.outputs.change }}

+
+

PR(s):

+

${{ steps.extract-data.outputs.pr_url }}

+

+

Link da task no Azure:

+

${{ steps.extract-data.outputs.task_link }}

+

+

Responsáveis:

+

Dev: ${{ steps.extract-data.outputs.dev }}

+

TL: ${{ steps.extract-data.outputs.tl }}

+

Team: ${{ steps.extract-data.outputs.team }}

+

+

Aprovador:

+

${{ steps.extract-data.outputs.approver }}

+ EOF + ) + + GMUD_JSON=$(jq -n --arg name "[${{ steps.extract-data.outputs.service }}] - ${{ steps.extract-data.outputs.summary }}" \ + --arg content "$GMUD_CONTENT" \ + --arg dev "${{ steps.extract-data.outputs.dev }}" \ + --arg tl "${{ steps.extract-data.outputs.tl }}" \ + --arg impact "${{ steps.extract-data.outputs.impact }}" \ + '{ + "input": { + "name": $name, + "content": $content, + "type": "change", + "status": "1", + "impact": "3", + "urgency": "3", + "itilcategories_id": "1", + "devfield": $dev, + "qafield": $tl, + "rolloutplancontent": "

Merge+do+PR+após+aprovação.

", + "impactcontent": $impact + } + }') + + echo "GMUD JSON payload:" + echo "$GMUD_JSON" | jq . 2>/dev/null || { + echo "Error: Invalid JSON payload" + echo "$GMUD_JSON" + exit 1 + } + + RESPONSE=$(curl -s -w "%{http_code}" -X POST \ + -H "App-Token: $GLPI_APP_TOKEN" \ + -H "Session-Token: $SESSION_TOKEN" \ + -H "Content-Type: application/json" \ + -d "$GMUD_JSON" \ + "$GLPI_API_URL/Change" -o response.json 2> curl_error.log || echo "Curl failed with exit code $?") + + echo "HTTP Status: $RESPONSE - $GLPI_API_URL" + + if [ -s curl_error.log ]; then + echo "Curl error output:" + cat curl_error.log + fi + + if [ -f response.json ]; then + echo "Response content:" + cat response.json + else + echo "Error: response.json was not created" + exit 1 + fi + + if [ -n "$RESPONSE" ] && [ "$RESPONSE" -ge 400 ] 2>/dev/null; then + echo "Error: API request failed with status $RESPONSE" + exit 1 + elif [ -z "$RESPONSE" ]; then + echo "Error: No HTTP status code returned." + exit 1 + fi From a49b9b11e312ca9f2b69860d587aa224b183fec9 Mon Sep 17 00:00:00 2001 From: Diego Morais <104941487+diego-dm-morais@users.noreply.github.com> Date: Fri, 27 Jun 2025 09:46:43 -0300 Subject: [PATCH 33/55] feat: update sonarqube (#6) * feat: update pipeline test * feat: update pipeline test * feat: update pipeline test * feat: update pipeline test --- sonarqube-python/action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index c7a687a..5d9d934 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -46,6 +46,10 @@ inputs: sonar-project-key: required: true type: string + sonar-timeout: + required: false + type: string + default: "60" runs: using: composite @@ -64,6 +68,10 @@ runs: -Dsonar.python.coverage.reportPaths=${{ inputs.sonar-report-paths }} -Dsonar.verbose=${{ inputs.sonar-verbose }} -Dsonar.sourceEncoding=${{ inputs.sonar-source-encoding }} + -Dsonar.ws.timeout=${{ inputs.sonar-timeout }} + -Dsonar.scanner.connectTimeout=30000 + -Dsonar.scanner.readTimeout=30000 + -Dsonar.scanner.skipSystemTruststore=true env: SONAR_TOKEN: ${{ inputs.sonar-token }} SONAR_HOST_URL: ${{ inputs.sonar-host-url }} From 3a9473e0d8cf4d38e4ae02c499d51a1b44e442fd Mon Sep 17 00:00:00 2001 From: Diego Morais <104941487+diego-dm-morais@users.noreply.github.com> Date: Fri, 27 Jun 2025 10:00:12 -0300 Subject: [PATCH 34/55] feat: update pipeline test (#7) --- sonarqube-python/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index 5d9d934..5c44ea1 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -68,9 +68,9 @@ runs: -Dsonar.python.coverage.reportPaths=${{ inputs.sonar-report-paths }} -Dsonar.verbose=${{ inputs.sonar-verbose }} -Dsonar.sourceEncoding=${{ inputs.sonar-source-encoding }} - -Dsonar.ws.timeout=${{ inputs.sonar-timeout }} - -Dsonar.scanner.connectTimeout=30000 - -Dsonar.scanner.readTimeout=30000 + -Dsonar.scanner.connectTimeout=${{ inputs.sonar-timeout }} + -Dsonar.scanner.socketTimeout=${{ inputs.sonar-timeout }} + -Dsonar.scanner.readTimeout=${{ inputs.sonar-timeout }} -Dsonar.scanner.skipSystemTruststore=true env: SONAR_TOKEN: ${{ inputs.sonar-token }} From fe44d03d1417ef1acfcaac507967021019cca14e Mon Sep 17 00:00:00 2001 From: Juan Ferreira Oioli <56684223+JuanOioli@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:05:48 -0300 Subject: [PATCH 35/55] Feat: Creating Bump Tag Action (#8) * add tag bump feature * add dockerfile on bump tag feature * fix dockerfile * edit desctiptions --- tag-bump/Dockerfile | 7 ++ tag-bump/action.sh | 293 ++++++++++++++++++++++++++++++++++++++++++++ tag-bump/action.yml | 13 ++ 3 files changed, 313 insertions(+) create mode 100644 tag-bump/Dockerfile create mode 100755 tag-bump/action.sh create mode 100644 tag-bump/action.yml diff --git a/tag-bump/Dockerfile b/tag-bump/Dockerfile new file mode 100644 index 0000000..01bc88c --- /dev/null +++ b/tag-bump/Dockerfile @@ -0,0 +1,7 @@ +FROM node:20-alpine + +RUN apk --no-cache add bash git git-lfs curl jq && npm install -g semver + +COPY action.sh /action.sh + +ENTRYPOINT ["/action.sh"] diff --git a/tag-bump/action.sh b/tag-bump/action.sh new file mode 100755 index 0000000..fd4b911 --- /dev/null +++ b/tag-bump/action.sh @@ -0,0 +1,293 @@ +#!/bin/bash + +set -eo pipefail + +# config +default_semvar_bump=${DEFAULT_BUMP:-minor} +default_branch=${DEFAULT_BRANCH:-$GITHUB_BASE_REF} # get the default branch from github runner env vars +with_v=${WITH_V:-false} +release_branches=${RELEASE_BRANCHES:-master,main} +custom_tag=${CUSTOM_TAG:-} +source=${SOURCE:-.} +dryrun=${DRY_RUN:-false} +git_api_tagging=${GIT_API_TAGGING:-true} +initial_version=${INITIAL_VERSION:-0.0.0} +tag_context=${TAG_CONTEXT:-repo} +tag_prefix=${TAG_PREFIX:-false} +prerelease=${PRERELEASE:-false} +suffix=${PRERELEASE_SUFFIX:-beta} +verbose=${VERBOSE:-false} +major_string_token=${MAJOR_STRING_TOKEN:-#major} +minor_string_token=${MINOR_STRING_TOKEN:-#minor} +patch_string_token=${PATCH_STRING_TOKEN:-#patch} +none_string_token=${NONE_STRING_TOKEN:-#none} +branch_history=${BRANCH_HISTORY:-compare} +force_without_changes=${FORCE_WITHOUT_CHANGES:-false} +force_without_changes_pre=${FORCE_WITHOUT_CHANGES:-false} +tag_message=${TAG_MESSAGE:-""} + +# since https://github.blog/2022-04-12-git-security-vulnerability-announced/ runner uses? +git config --global --add safe.directory /github/workspace + +cd "${GITHUB_WORKSPACE}/${source}" || exit 1 + +echo "*** CONFIGURATION ***" +echo -e "\tDEFAULT_BUMP: ${default_semvar_bump}" +echo -e "\tDEFAULT_BRANCH: ${default_branch}" +echo -e "\tWITH_V: ${with_v}" +echo -e "\tRELEASE_BRANCHES: ${release_branches}" +echo -e "\tCUSTOM_TAG: ${custom_tag}" +echo -e "\tSOURCE: ${source}" +echo -e "\tDRY_RUN: ${dryrun}" +echo -e "\tGIT_API_TAGGING: ${git_api_tagging}" +echo -e "\tINITIAL_VERSION: ${initial_version}" +echo -e "\tTAG_CONTEXT: ${tag_context}" +echo -e "\tTAG_PREFIX: ${tag_prefix}" +echo -e "\tPRERELEASE: ${prerelease}" +echo -e "\tPRERELEASE_SUFFIX: ${suffix}" +echo -e "\tVERBOSE: ${verbose}" +echo -e "\tMAJOR_STRING_TOKEN: ${major_string_token}" +echo -e "\tMINOR_STRING_TOKEN: ${minor_string_token}" +echo -e "\tPATCH_STRING_TOKEN: ${patch_string_token}" +echo -e "\tNONE_STRING_TOKEN: ${none_string_token}" +echo -e "\tBRANCH_HISTORY: ${branch_history}" +echo -e "\tFORCE_WITHOUT_CHANGES: ${force_without_changes}" +echo -e "\tFORCE_WITHOUT_CHANGES_PRE: ${force_without_changes_pre}" +echo -e "\tTAG_MESSAGE: ${tag_message}" + +# verbose, show everything +if $verbose +then + set -x +fi + +setOutput() { + echo "${1}=${2}" >> "${GITHUB_OUTPUT}" +} + +current_branch=$(git rev-parse --abbrev-ref HEAD) + +pre_release="$prerelease" +IFS=',' read -ra branch <<< "$release_branches" +for b in "${branch[@]}"; do + # check if ${current_branch} is in ${release_branches} | exact branch match + if [[ "$current_branch" == "$b" ]] + then + pre_release="false" + fi + # verify non specific branch names like .* release/* if wildcard filter then =~ + if [ "$b" != "${b//[\[\]|.? +*]/}" ] && [[ "$current_branch" =~ $b ]] + then + pre_release="false" + fi +done +echo "pre_release = $pre_release" + +# fetch tags +git fetch --tags + +# Set no tag prefix (not even v) +tagPrefix="" + +if $with_v +then + tagPrefix="v" +fi + +# If a tag_prefix is supplied use that +if [[ "${tag_prefix}" != "false" ]] +then + tagPrefix=$tag_prefix +fi + +tagFmt="^$tagPrefix?[0-9]+\.[0-9]+\.[0-9]+$" +preTagFmt="^$tagPrefix?[0-9]+\.[0-9]+\.[0-9]+(-$suffix\.[0-9]+)$" + +# get the git refs +git_refs= +case "$tag_context" in + *repo*) + git_refs=$(git for-each-ref --sort=-v:refname --format '%(refname:lstrip=2)') + ;; + *branch*) + git_refs=$(git tag --list --merged HEAD --sort=-committerdate) + ;; + * ) echo "Unrecognised context" + exit 1;; +esac + +# get the latest tag that looks like a semver (with or without v) +matching_tag_refs=$( (grep -E "$tagFmt" <<< "$git_refs") || true) +matching_pre_tag_refs=$( (grep -E "$preTagFmt" <<< "$git_refs") || true) +tag=$(head -n 1 <<< "$matching_tag_refs") +pre_tag=$(head -n 1 <<< "$matching_pre_tag_refs") + +# if there are none, start tags at initial version +if [ -z "$tag" ] +then + tag="$tagPrefix$initial_version" + if [ -z "$pre_tag" ] && $pre_release + then + pre_tag="$tagPrefix$initial_version" + fi +fi + +# get current commit hash for tag +tag_commit=$(git rev-list -n 1 "$tag" || true ) +# get current commit hash +commit=$(git rev-parse HEAD) +# skip if there are no new commits for non-pre_release +if [ "$tag_commit" == "$commit" ] && [ "$force_without_changes" == "false" ] +then + echo "No new commits since previous tag. Skipping..." + setOutput "new_tag" "$tag" + setOutput "tag" "$tag" + exit 0 +fi + +# sanitize that the default_branch is set (via env var when running on PRs) else find it natively +if [ -z "${default_branch}" ] && [ "$branch_history" == "full" ] +then + echo "The DEFAULT_BRANCH should be autodetected when tag-action runs on on PRs else must be defined, See: https://github.com/anothrNick/github-tag-action/pull/230, since is not defined we find it natively" + default_branch=$(git branch -rl '*/master' '*/main' | cut -d / -f2) + echo "default_branch=${default_branch}" + # re check this + if [ -z "${default_branch}" ] + then + echo "::error::DEFAULT_BRANCH must not be null, something has gone wrong." + exit 1 + fi +fi + +# get the merge commit message looking for #bumps +declare -A history_type=( + ["last"]="$(git show -s --format=%B)" \ + ["full"]="$(git log "${default_branch}"..HEAD --format=%B)" \ + ["compare"]="$(git log "${tag_commit}".."${commit}" --format=%B)" \ +) +log=${history_type[${branch_history}]} +printf "History:\n---\n%s\n---\n" "$log" + +if [ -z "$tagPrefix" ] +then + current_tag=${tag} +else + current_tag="$(echo ${tag}| sed "s/${tagPrefix}//g")" +fi +case "$log" in + *$major_string_token* ) new=${tagPrefix}$(semver -i major "${current_tag}"); part="major";; + *$minor_string_token* ) new=${tagPrefix}$(semver -i minor "${current_tag}"); part="minor";; + *$patch_string_token* ) new=${tagPrefix}$(semver -i patch "${current_tag}"); part="patch";; + *$none_string_token* ) + echo "Default bump was set to none. Skipping..." + setOutput "old_tag" "$tag" + setOutput "new_tag" "$tag" + setOutput "tag" "$tag" + setOutput "part" "$default_semvar_bump" + exit 0;; + * ) + if [ "$default_semvar_bump" == "none" ] + then + echo "Default bump was set to none. Skipping..." + setOutput "old_tag" "$tag" + setOutput "new_tag" "$tag" + setOutput "tag" "$tag" + setOutput "part" "$default_semvar_bump" + exit 0 + else + new=${tagPrefix}$(semver -i "${default_semvar_bump}" "${current_tag}") + part=$default_semvar_bump + fi + ;; +esac + +if $pre_release +then + # get current commit hash for tag + pre_tag_commit=$(git rev-list -n 1 "$pre_tag" || true) + # skip if there are no new commits for pre_release + if [ "$pre_tag_commit" == "$commit" ] && [ "$force_without_changes_pre" == "false" ] + then + echo "No new commits since previous pre_tag. Skipping..." + setOutput "new_tag" "$pre_tag" + setOutput "tag" "$pre_tag" + exit 0 + fi + # already a pre-release available, bump it + if [[ "$pre_tag" =~ $new ]] && [[ "$pre_tag" =~ $suffix ]] + then + new=${tagPrefix}$(semver -i prerelease "${pre_tag}" --preid "${suffix}") + echo -e "Bumping ${suffix} pre-tag ${pre_tag}. New pre-tag ${new}" + else + new="${tagPrefix}${new}-${suffix}.0" + echo -e "Setting ${suffix} pre-tag ${pre_tag} - With pre-tag ${new}" + fi + part="pre-$part" +else + echo -e "Bumping tag ${tag} - New tag ${new}" +fi + +# as defined in readme if CUSTOM_TAG is used any semver calculations are irrelevant. +if [ -n "$custom_tag" ] +then + new="$custom_tag" +fi + +# set outputs +setOutput "new_tag" "$new" +setOutput "part" "$part" +setOutput "tag" "$new" # this needs to go in v2 is breaking change +setOutput "old_tag" "$tag" + +# dry run exit without real changes +if $dryrun +then + exit 0 +fi + +# Modify the tag creation part +if [ -n "$tag_message" ] +then + echo "EVENT: creating local tag $new with message: $tag_message" + git tag -a "$new" -m "$tag_message" || exit 1 +else + echo "EVENT: creating local tag $new" + git tag -f "$new" || exit 1 +fi + +echo "EVENT: pushing tag $new to origin" + +if $git_api_tagging +then + # use git api to push + dt=$(date '+%Y-%m-%dT%H:%M:%SZ') + full_name=$GITHUB_REPOSITORY + git_refs_url=$(jq .repository.git_refs_url "$GITHUB_EVENT_PATH" | tr -d '"' | sed 's/{\/sha}//g') + + echo "$dt: **pushing tag $new to repo $full_name" + + git_refs_response=$( + curl -s -X POST "$git_refs_url" \ + -H "Authorization: token $GITHUB_TOKEN" \ + -d @- << EOF +{ + "ref": "refs/tags/$new", + "sha": "$commit" +} +EOF +) + + git_ref_posted=$( echo "${git_refs_response}" | jq .ref | tr -d '"' ) + + echo "::debug::${git_refs_response}" + if [ "${git_ref_posted}" = "refs/tags/${new}" ] + then + exit 0 + else + echo "::error::Tag was not created properly." + exit 1 + fi +else + # use git cli to push + git push -f origin "$new" || exit 1 +fi diff --git a/tag-bump/action.yml b/tag-bump/action.yml new file mode 100644 index 0000000..ac1e1f2 --- /dev/null +++ b/tag-bump/action.yml @@ -0,0 +1,13 @@ +name: Create Tag +description: Create Tag to be reused by rollback feature + +runs: + using: 'docker' + image: 'Dockerfile' +outputs: + new_tag: + description: 'Generated tag' + tag: + description: 'The latest tag after running this action' + part: + description: 'The part of version which was bumped' From 940d6db2b32fcc05fe1f2255ebdd3ce85a9d6daa Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Wed, 2 Jul 2025 09:59:37 -0300 Subject: [PATCH 36/55] Removing if need run to workflow --- gmud-creator/action.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index f7196c2..4e3d981 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -11,17 +11,12 @@ inputs: glpi_user_token: description: "The user token for GLPI" required: true - create_gmud: - description: "Flag to determine if GMUD should be created" - required: true - default: "false" runs: using: "composite" steps: - name: Validate GLPI_API_URL format shell: bash - if: ${{ inputs.create_gmud == 'true' }} run: | if [[ ! "$GLPI_API_URL" =~ ^https?:// ]]; then echo "Error: GLPI_API_URL does not start with http:// or https://" @@ -32,7 +27,6 @@ runs: GLPI_API_URL: ${{ inputs.glpi_api_url }} - name: Extract PR Data - if: ${{ inputs.create_gmud == 'true' }} id: extract-data uses: actions/github-script@v6 with: @@ -90,7 +84,6 @@ runs: core.setOutput('pr_url', context.payload.pull_request.html_url); - name: Create GMUD via API - if: ${{ inputs.create_gmud == 'true' }} shell: bash env: GLPI_API_URL: ${{ inputs.glpi_api_url }} From 4a75a77dcd5478805f5e8b08e76d2308e7d73db0 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Wed, 2 Jul 2025 10:41:20 -0300 Subject: [PATCH 37/55] Fix: field of function --- gmud-creator/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index 4e3d981..e0a47d9 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -45,7 +45,7 @@ runs: function extractResponsible(field) { const regex = new RegExp(`\\*\\*${field}:\\*\\*\\s*\\[(@?[\\w\\s.-]+)\\]`, 'i'); - const match = text.match(regex); + const match = field.match(regex); return (match || [])[1] || 'Não especificado'; }; From 3fab3d461ba9ab782dbb28831258baa05ebffb93 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Thu, 3 Jul 2025 09:24:01 -0300 Subject: [PATCH 38/55] Fix: Regex to get responsible --- gmud-creator/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index e0a47d9..985a34a 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -44,8 +44,8 @@ runs: }; function extractResponsible(field) { - const regex = new RegExp(`\\*\\*${field}:\\*\\*\\s*\\[(@?[\\w\\s.-]+)\\]`, 'i'); - const match = field.match(regex); + const regex = new RegExp(`\\*\\*${field}:\\*\\*\\s*\\[(.*?)\\]`, 'i'); + const match = pbody.match(regex); return (match || [])[1] || 'Não especificado'; }; From 7ce61138c712eface27d125f9ebe6a6be2b9bf63 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Thu, 3 Jul 2025 13:09:42 -0300 Subject: [PATCH 39/55] Adding Slack Test channel --- gmud-creator/action.yml | 86 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index 985a34a..21e4158 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -54,8 +54,8 @@ runs: /-\s\[x\]\s\*\*Não Programada\*\*/i.test(prBody) ? 'Não Programada' : /-\s\[x\]\s\*\*Programada\*\*/i.test(prBody) ? 'Programada' : ''; + const tested = /-\s\[x\]\s\*\*Confirmo\*\*/i.test(prBody) ? 'Sim' : 'Não'; - const service = extractSection('Serviço Afetado'); const summary = extractSection('Descrição Resumida'); const contxt = extractSection('Contexto'); const problem = extractSection('Problema') || 'N/A'; @@ -70,7 +70,6 @@ runs: // Output para os próximos passos core.setOutput('change_type', changeType); - core.setOutput('service', service); core.setOutput('summary', summary); core.setOutput('context', contxt); core.setOutput('problem', problem); @@ -82,6 +81,7 @@ runs: core.setOutput('impact', impact); core.setOutput('task_link', task_link); core.setOutput('pr_url', context.payload.pull_request.html_url); + core.setOutput('tested', tested); - name: Create GMUD via API shell: bash @@ -118,6 +118,8 @@ runs: fi GMUD_CONTENT=$(cat <Confirmo que foi testado em ambiente de homologação:

+

${{ steps.extract-data.outputs.tested }}

Contexto:

${{ steps.extract-data.outputs.context }}


@@ -143,7 +145,7 @@ runs: EOF ) - GMUD_JSON=$(jq -n --arg name "[${{ steps.extract-data.outputs.service }}] - ${{ steps.extract-data.outputs.summary }}" \ + GMUD_JSON=$(jq -n --arg name "[${{ github.repository }}] - ${{ steps.extract-data.outputs.summary }}" \ --arg content "$GMUD_CONTENT" \ --arg dev "${{ steps.extract-data.outputs.dev }}" \ --arg tl "${{ steps.extract-data.outputs.tl }}" \ @@ -200,3 +202,81 @@ runs: echo "Error: No HTTP status code returned." exit 1 fi + + - name: Extract GLPI GMUD ID + id: glpi-id + shell: bash + run: | + if [ -f response.json ]; then + GMUD_ID=$(jq -r '.id' response.json) + echo "GMUD_ID=$GMUD_ID" >> $GITHUB_OUTPUT + echo "GLPI GMUD ID: $GMUD_ID" + else + echo "Error: response.json not found" + exit 1 + fi + + - name: Send GMUD payload notification + if: ${{ github.ref_name == 'main' }} + uses: archive/github-actions-slack@v2.9.0 + with: + slack-bot-user-oauth-access-token: ${{ secrets.SLACK_NOBOT_TOKEN }} + slack-channel: 'C093VDRV5CP' + slack-blocks: | + [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "📢 Nova GMUD Criada 📢", + "emoji": true + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Repositório:*\n${{ github.repository }}" + }, + { + "type": "mrkdwn", + "text": "*Tipo de Mudança:*\n${{ steps.extract-data.outputs.change_type }}" + } + ] + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Descrição:*\n${{ steps.extract-data.outputs.summary }}" + } + }, + { + "type": "divider" + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Abrir no GLPI", + "emoji": true + }, + "url": "https://suporte.dotz.com.br/front/change.form.php?id=${{ steps.glpi-id.outputs.GMUD_ID }}", + "style": "primary" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Ver PR no GitHub", + "emoji": true + }, + "url": "${{ steps.extract-data.outputs.pr_url }}" + } + ] + } + ] \ No newline at end of file From 21ada320e1e2ae1bb3d4bd3bde236ab46c90f6cf Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Thu, 3 Jul 2025 13:46:39 -0300 Subject: [PATCH 40/55] Adding vars inherit secrets --- gmud-creator/action.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index 21e4158..500cc37 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -11,6 +11,12 @@ inputs: glpi_user_token: description: "The user token for GLPI" required: true + slack-bot-user-oauth-access-token: + description: "Slack Bot User OAuth Access Token for sending notifications" + required: true + slack-channel: + description: "Slack channel to send notifications" + required: true runs: using: "composite" @@ -217,10 +223,9 @@ runs: fi - name: Send GMUD payload notification - if: ${{ github.ref_name == 'main' }} uses: archive/github-actions-slack@v2.9.0 with: - slack-bot-user-oauth-access-token: ${{ secrets.SLACK_NOBOT_TOKEN }} + slack-bot-user-oauth-access-token: ${{ inputs.slack-bot-user-oauth-access-token }} slack-channel: 'C093VDRV5CP' slack-blocks: | [ From 8e53c4334555ee2defab84e4bb245934ffef1872 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Thu, 3 Jul 2025 13:59:58 -0300 Subject: [PATCH 41/55] Fix: variables pattern --- gmud-creator/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index 500cc37..cdf40e8 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -11,10 +11,10 @@ inputs: glpi_user_token: description: "The user token for GLPI" required: true - slack-bot-user-oauth-access-token: + slack_bot_user_oauth_access_token: description: "Slack Bot User OAuth Access Token for sending notifications" required: true - slack-channel: + slack_channel: description: "Slack channel to send notifications" required: true @@ -225,7 +225,7 @@ runs: - name: Send GMUD payload notification uses: archive/github-actions-slack@v2.9.0 with: - slack-bot-user-oauth-access-token: ${{ inputs.slack-bot-user-oauth-access-token }} + slack-bot-user-oauth-access-token: ${{ inputs.slack_bot_user_oauth_access_token }} slack-channel: 'C093VDRV5CP' slack-blocks: | [ From 985063001b1f574ee1dcd47147de9e16cb4033fe Mon Sep 17 00:00:00 2001 From: Diego Morais <104941487+diego-dm-morais@users.noreply.github.com> Date: Thu, 3 Jul 2025 16:33:37 -0300 Subject: [PATCH 42/55] feat: add sonarqube dot net (#13) * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube --- sonarqube-dotnet/action.yml | 91 +++++++++++++++++++++ sonarqube-dotnet/coverage-calc.sh | 7 ++ sonarqube-dotnet/quality-gates-sonarqube.sh | 40 +++++++++ sonarqube-dotnet/sonarqube-status.sh | 22 +++++ sonarqube-python/action.yml | 3 +- 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 sonarqube-dotnet/action.yml create mode 100755 sonarqube-dotnet/coverage-calc.sh create mode 100755 sonarqube-dotnet/quality-gates-sonarqube.sh create mode 100755 sonarqube-dotnet/sonarqube-status.sh diff --git a/sonarqube-dotnet/action.yml b/sonarqube-dotnet/action.yml new file mode 100644 index 0000000..8750202 --- /dev/null +++ b/sonarqube-dotnet/action.yml @@ -0,0 +1,91 @@ +name: 'Sonarqube .NET Scanner' +description: 'Quality Gate Sonarqube for .NET projects' + +inputs: + sonar-verbose: + required: false + type: boolean + default: false + sonar-sources: + required: false + type: string + default: "." + sonar-report-paths: + required: false + type: string + default: "coverage.xml" + sonar-source-encoding: + required: false + type: string + default: "UTF-8" + sonar-exclusions: + required: false + type: string + default: "**/bin/**,**/obj/**,**/TestResults/**,**/Tests/**,**/*.py" + sonar-host-url: + required: true + type: string + sonar-api-token: + required: true + type: string + sonar-token: + required: true + type: string + sonar-project-key: + required: true + type: string + sonar-timeout: + required: false + type: string + default: "300" + sonar-dotnet-version: + required: false + type: string + default: "8.0.x" + +runs: + using: composite + steps: + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@v5.2.0 + with: + args: > + -Dsonar.sources="${{ inputs.sonar-sources }}" + -Dsonar.projectKey="${{ inputs.sonar-project-key }}" + -Dsonar.projectName="${{ inputs.sonar-project-key }}" + -Dsonar.cs.opencover.reportsPaths="${{ inputs.sonar-report-paths }}" + -Dsonar.exclusions="${{ inputs.sonar-exclusions }}" + -Dsonar.scanner.skipSystemTruststore=true + -Dsonar.scanner.forceReload=true + env: + SONAR_TOKEN: ${{ inputs.sonar-token }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + + - name: Check SonarQube Quality Gate Status + id: sonarqube-status + shell: bash + continue-on-error: true + run: ${{ github.action_path }}/sonarqube-status.sh + env: + SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} + SONAR_TOKEN: ${{ inputs.sonar-api-token }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + + - name: Get Coverage + shell: bash + id: coverage-calc + if: steps.sonarqube-status.outputs.status == 'OK' + continue-on-error: true + run: ${{ github.action_path }}/coverage-calc.sh + + - name: Update Quality Gates Sonarqube + shell: bash + id: quality-gates-sonarqube + if: steps.sonarqube-status.outputs.status == 'OK' + continue-on-error: true + run: ${{ github.action_path }}/quality-gates-sonarqube.sh + env: + SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} + SONAR_TOKEN: ${{ inputs.sonar-api-token }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + LEGACY_COV_NUM: ${{ steps.coverage-calc.outputs.coverage }} diff --git a/sonarqube-dotnet/coverage-calc.sh b/sonarqube-dotnet/coverage-calc.sh new file mode 100755 index 0000000..b94fc77 --- /dev/null +++ b/sonarqube-dotnet/coverage-calc.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +COVERAGE=$(python -c "import xml.etree.ElementTree as ET; \ +print(float(ET.parse('coverage.xml').getroot().attrib['line-rate']) * 100)") + +echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT +echo "legacy_coverage=$COVERAGE" >> $GITHUB_OUTPUT diff --git a/sonarqube-dotnet/quality-gates-sonarqube.sh b/sonarqube-dotnet/quality-gates-sonarqube.sh new file mode 100755 index 0000000..3cb5c5f --- /dev/null +++ b/sonarqube-dotnet/quality-gates-sonarqube.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +PROJECT_RESPONSE=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/get_by_project?project=$SONAR_PROJECT_KEY") + +QUALITY_GATE_NAME=$(echo "$PROJECT_RESPONSE" | jq -r '.qualityGate.name') +QUALITY_GATE_NAME=$(echo "$QUALITY_GATE_NAME" | jq -sRr @uri) + +echo "Quality Gate Name: $QUALITY_GATE_NAME" + +GATE_RESPONSE=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/show?name=$QUALITY_GATE_NAME") + +NEW_COV_CONDITION_ID=$(echo "$GATE_RESPONSE" | jq -r '.conditions[] | select(.metric=="coverage") | .id') +CURRENT_NEW_COV=$(echo "$GATE_RESPONSE" | jq -r '.conditions[] | select(.metric=="coverage") | .error') + +if [ -n "$NEW_COV_CONDITION_ID" ]; then + CURRENT_NEW_COV_NUM=$(echo "$CURRENT_NEW_COV" | sed 's/[^0-9.]*//g') + + if (( $(echo "$LEGACY_COV_NUM > $CURRENT_NEW_COV_NUM" | bc -l) )); then + if (( $(echo "$LEGACY_COV_NUM > 80" | bc -l) )); then + echo "Legacy coverage ($LEGACY_COV_NUM%) > 80%, updating coverage threshold to 80%" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/update_condition" \ + -d "id=$NEW_COV_CONDITION_ID&metric=coverage&op=LT&error=80" + else + echo "Updating coverage threshold from $CURRENT_NEW_COV to $LEGACY_COV_NUM%" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/update_condition" \ + -d "id=$NEW_COV_CONDITION_ID&metric=coverage&op=LT&error=$LEGACY_COV_NUM" + fi + else + echo "Legacy coverage ($LEGACY_COV_NUM%) not greater than current coverage ($CURRENT_NEW_COV), keeping existing configuration" + fi +else + echo "Criando nova condição para coverage" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/create_condition" \ + -d "gateName=$QUALITY_GATE_NAME&metric=coverage&op=LT&error=$LEGACY_COV_NUM" +fi diff --git a/sonarqube-dotnet/sonarqube-status.sh b/sonarqube-dotnet/sonarqube-status.sh new file mode 100755 index 0000000..16bf123 --- /dev/null +++ b/sonarqube-dotnet/sonarqube-status.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +sleep 10 +SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$SONAR_PROJECT_KEY") + +# Extract overall status +STATUS=$(echo "$SONAR_STATUS" | jq -r '.projectStatus.status') + +# Process failing conditions +echo "SonarQube Quality Gate Status: $STATUS" +if [ "$STATUS" != "OK" ]; then + echo "=== Failing Conditions ===" + echo "$SONAR_STATUS" | jq -r '.projectStatus.conditions[] | select(.status != "OK") | "Metric: \(.metricKey) | Threshold: \(.errorThreshold) | Actual: \(.actualValue)"' + + echo "status=$STATUS" >> $GITHUB_OUTPUT + echo "::error::Quality Gate failed with status: $STATUS" + exit 1 +fi + +echo "status=$STATUS" >> $GITHUB_OUTPUT +echo "Quality Gate passed successfully!" diff --git a/sonarqube-python/action.yml b/sonarqube-python/action.yml index 5c44ea1..4f4e6c0 100644 --- a/sonarqube-python/action.yml +++ b/sonarqube-python/action.yml @@ -62,7 +62,7 @@ runs: -Dsonar.projectKey=${{ inputs.sonar-project-key }} -Dsonar.sources=${{ inputs.sonar-sources }} -Dsonar.tests=${{ inputs.sonar-sources-tests }} - -Dsonar.test.inclusions=${{inputs.sonar-test-inclusions }} + -Dsonar.test.inclusions=${{ inputs.sonar-test-inclusions }} -Dsonar.exclusions=${{ inputs.sonar-exclusions }} -Dsonar.python.version=${{ inputs.sonar-lang-version }} -Dsonar.python.coverage.reportPaths=${{ inputs.sonar-report-paths }} @@ -72,6 +72,7 @@ runs: -Dsonar.scanner.socketTimeout=${{ inputs.sonar-timeout }} -Dsonar.scanner.readTimeout=${{ inputs.sonar-timeout }} -Dsonar.scanner.skipSystemTruststore=true + -Dsonar.scanner.forceReload=true env: SONAR_TOKEN: ${{ inputs.sonar-token }} SONAR_HOST_URL: ${{ inputs.sonar-host-url }} From e81c490dcf6b887fa8c952b21284db8b790ec810 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Fri, 4 Jul 2025 07:24:56 -0300 Subject: [PATCH 43/55] Fix: copy variable --- gmud-creator/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index cdf40e8..4d6f2a7 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -51,7 +51,7 @@ runs: function extractResponsible(field) { const regex = new RegExp(`\\*\\*${field}:\\*\\*\\s*\\[(.*?)\\]`, 'i'); - const match = pbody.match(regex); + const match = prBody.match(regex); return (match || [])[1] || 'Não especificado'; }; From 32ec6be19026ddff6f96c4e009cd49ac229f9666 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Fri, 4 Jul 2025 07:36:55 -0300 Subject: [PATCH 44/55] Fix: Channel ID --- gmud-creator/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index 4d6f2a7..abdbb23 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -226,7 +226,7 @@ runs: uses: archive/github-actions-slack@v2.9.0 with: slack-bot-user-oauth-access-token: ${{ inputs.slack_bot_user_oauth_access_token }} - slack-channel: 'C093VDRV5CP' + slack-channel: C093VDRV5CP slack-blocks: | [ { From 877c54c4a0c51d1d238dce3b605a290182381581 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Fri, 4 Jul 2025 08:06:54 -0300 Subject: [PATCH 45/55] Adding GMUD channel ID --- gmud-creator/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index abdbb23..8365f67 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -226,7 +226,7 @@ runs: uses: archive/github-actions-slack@v2.9.0 with: slack-bot-user-oauth-access-token: ${{ inputs.slack_bot_user_oauth_access_token }} - slack-channel: C093VDRV5CP + slack-channel: ${{ inputs.slack_channel }} slack-blocks: | [ { From 84f90396f5d143becdabf758c3adf94c52557438 Mon Sep 17 00:00:00 2001 From: Diego Morais <104941487+diego-dm-morais@users.noreply.github.com> Date: Fri, 4 Jul 2025 09:56:31 -0300 Subject: [PATCH 46/55] feat: add sonarqube (#16) * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube --- sonarqube-dotnet/action.yml | 17 ++++++++++++----- sonarqube-dotnet/sonarqube-status.sh | 2 +- sonarqube-python/sonarqube-status.sh | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sonarqube-dotnet/action.yml b/sonarqube-dotnet/action.yml index 8750202..11e99f1 100644 --- a/sonarqube-dotnet/action.yml +++ b/sonarqube-dotnet/action.yml @@ -42,6 +42,10 @@ inputs: required: false type: string default: "8.0.x" + sonar-project-name: + required: true + type: string + runs: using: composite @@ -50,13 +54,16 @@ runs: uses: sonarsource/sonarqube-scan-action@v5.2.0 with: args: > - -Dsonar.sources="${{ inputs.sonar-sources }}" - -Dsonar.projectKey="${{ inputs.sonar-project-key }}" - -Dsonar.projectName="${{ inputs.sonar-project-key }}" - -Dsonar.cs.opencover.reportsPaths="${{ inputs.sonar-report-paths }}" - -Dsonar.exclusions="${{ inputs.sonar-exclusions }}" + -Dsonar.inclusions=**/*.cs + -Dsonar.sources=${{ inputs.sonar-sources }} + -Dsonar.projectBaseDir=${{ inputs.sonar-sources }} + -Dsonar.projectKey=${{ inputs.sonar-project-key }} + -Dsonar.projectName=${{ inputs.sonar-project-name }} + -Dsonar.cs.opencover.reportsPaths=${{ inputs.sonar-report-paths }} + -Dsonar.exclusions=${{ inputs.sonar-exclusions }} -Dsonar.scanner.skipSystemTruststore=true -Dsonar.scanner.forceReload=true + -Dsonar.cs.analyzer.projectOutPaths=bin/Debug/net8.0 env: SONAR_TOKEN: ${{ inputs.sonar-token }} SONAR_HOST_URL: ${{ inputs.sonar-host-url }} diff --git a/sonarqube-dotnet/sonarqube-status.sh b/sonarqube-dotnet/sonarqube-status.sh index 16bf123..7c2d912 100755 --- a/sonarqube-dotnet/sonarqube-status.sh +++ b/sonarqube-dotnet/sonarqube-status.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -sleep 10 +sleep 15 SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ "$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$SONAR_PROJECT_KEY") diff --git a/sonarqube-python/sonarqube-status.sh b/sonarqube-python/sonarqube-status.sh index 16bf123..7c2d912 100755 --- a/sonarqube-python/sonarqube-status.sh +++ b/sonarqube-python/sonarqube-status.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -sleep 10 +sleep 15 SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ "$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$SONAR_PROJECT_KEY") From 5ae5d55091c86208ecec3a724dab4119f7ecd5f3 Mon Sep 17 00:00:00 2001 From: Diego Morais <104941487+diego-dm-morais@users.noreply.github.com> Date: Mon, 7 Jul 2025 15:09:38 -0300 Subject: [PATCH 47/55] Feat: update sonarqube (#17) * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube * feat: add sonarqube --- sonarqube-dotnet/action.yml | 55 +++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/sonarqube-dotnet/action.yml b/sonarqube-dotnet/action.yml index 11e99f1..5b898ab 100644 --- a/sonarqube-dotnet/action.yml +++ b/sonarqube-dotnet/action.yml @@ -50,23 +50,44 @@ inputs: runs: using: composite steps: - - name: SonarQube Scan - uses: sonarsource/sonarqube-scan-action@v5.2.0 - with: - args: > - -Dsonar.inclusions=**/*.cs - -Dsonar.sources=${{ inputs.sonar-sources }} - -Dsonar.projectBaseDir=${{ inputs.sonar-sources }} - -Dsonar.projectKey=${{ inputs.sonar-project-key }} - -Dsonar.projectName=${{ inputs.sonar-project-name }} - -Dsonar.cs.opencover.reportsPaths=${{ inputs.sonar-report-paths }} - -Dsonar.exclusions=${{ inputs.sonar-exclusions }} - -Dsonar.scanner.skipSystemTruststore=true - -Dsonar.scanner.forceReload=true - -Dsonar.cs.analyzer.projectOutPaths=bin/Debug/net8.0 - env: - SONAR_TOKEN: ${{ inputs.sonar-token }} - SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + - name: Setup SonarScanner + shell: bash + run: | + # Install or update without failing if already installed + { dotnet tool update --global dotnet-sonarscanner || \ + { [ $? -eq 0 ] || dotnet tool install --global dotnet-sonarscanner; }; } && \ + echo "$HOME/.dotnet/tools" >> $GITHUB_PATH + + - name: Verify SonarScanner + shell: bash + run: | + echo "SonarScanner path: $(which dotnet-sonarscanner)" + echo "Version: $(dotnet-sonarscanner --version)" + + - name: Start SonarQube Analysis + shell: bash + run: | + dotnet-sonarscanner begin \ + /k:"${{ inputs.sonar-project-key }}" \ + /n:"${{ inputs.sonar-project-name }}" \ + /d:sonar.host.url="${{ inputs.sonar-host-url }}" \ + /d:sonar.login="${{ inputs.sonar-token }}" \ + /d:sonar.cs.opencover.reportsPaths="${{ inputs.sonar-report-paths }}" \ + /d:sonar.verbose="${{ inputs.sonar-verbose }}" + + - name: Restore NuGet packages + shell: bash + run: dotnet restore ${{ inputs.sonar-project-name }}.sln + + - name: Build Solution + shell: bash + run: dotnet build ${{ inputs.sonar-project-name }}.sln --no-restore + + - name: End SonarQube Analysis + shell: bash + run: | + dotnet-sonarscanner end \ + /d:sonar.login="${{ inputs.sonar-token }}" - name: Check SonarQube Quality Gate Status id: sonarqube-status From 01f98304c718e60e8a5c68a2b018842c93646aef Mon Sep 17 00:00:00 2001 From: Diego Morais <104941487+diego-dm-morais@users.noreply.github.com> Date: Thu, 10 Jul 2025 14:51:31 -0300 Subject: [PATCH 48/55] feat: add action sonarqube angular (#18) * feat: add sonarqube * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code * feat: update code --- sonarqube-angular/action.yml | 103 +++++++++++++++++++ sonarqube-angular/coverage-calc.sh | 7 ++ sonarqube-angular/quality-gates-sonarqube.sh | 40 +++++++ sonarqube-angular/sonarqube-status.sh | 22 ++++ 4 files changed, 172 insertions(+) create mode 100644 sonarqube-angular/action.yml create mode 100755 sonarqube-angular/coverage-calc.sh create mode 100755 sonarqube-angular/quality-gates-sonarqube.sh create mode 100755 sonarqube-angular/sonarqube-status.sh diff --git a/sonarqube-angular/action.yml b/sonarqube-angular/action.yml new file mode 100644 index 0000000..71fab6f --- /dev/null +++ b/sonarqube-angular/action.yml @@ -0,0 +1,103 @@ +name: 'Sonarqube Angular Scanner' +description: 'Quality Gate Sonarqube for Angular projects' + +inputs: + sonar-verbose: + required: false + type: boolean + default: false + sonar-sources: + required: false + type: string + default: "." + sonar-test-inclusions: + required: false + type: string + default: "**/*.spec.ts" + sonar-exclusions: + required: false + type: string + default: "**/*.html,**/*.css,**/*.scss,**/*.spec.ts,**/*.json,**/*.js" + sonar-source-encoding: + required: false + type: string + default: "UTF-8" + sonar-typescript-tsconfig-path: + required: false + type: string + default: "tsconfig.json" + sonar-report-paths: + required: false + type: string + default: "lcov.info" + sonar-host-url: + required: true + type: string + sonar-api-token: + required: true + type: string + sonar-token: + required: true + type: string + sonar-project-key: + required: true + type: string + sonar-timeout: + required: false + type: string + default: "300" + sonar-project-name: + required: true + type: string + node-version: + required: false + type: string + default: "20.x" + +runs: + using: composite + steps: + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@v5.2.0 + continue-on-error: true + with: + args: > + -Dsonar.projectKey=${{ inputs.sonar-project-key }} + -Dsonar.projectName="${{ inputs.sonar-project-key }}" + -Dsonar.sources="${{ inputs.sonar-sources }}" + -Dsonar.typescript.lcov.reportPaths=${{ inputs.sonar-report-paths }} + -Dsonar.exclusions=${{ inputs.sonar-exclusions }} + -Dsonar.verbose=${{ inputs.sonar-verbose }} + -Dsonar.sourceEncoding=${{ inputs.sonar-source-encoding }} + env: + SONAR_TOKEN: ${{ inputs.sonar-token }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + + - name: Check SonarQube Quality Gate Status + id: sonarqube-status + shell: bash + continue-on-error: true + run: ${{ github.action_path }}/sonarqube-status.sh + env: + SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} + SONAR_TOKEN: ${{ inputs.sonar-api-token }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + + - name: Get Coverage + shell: bash + id: coverage-calc + if: steps.sonarqube-status.outputs.status == 'OK' + continue-on-error: true + run: ${{ github.action_path }}/coverage-calc.sh + + - name: Update Quality Gates Sonarqube + shell: bash + id: quality-gates-sonarqube + if: steps.sonarqube-status.outputs.status == 'OK' + continue-on-error: true + run: ${{ github.action_path }}/quality-gates-sonarqube.sh + env: + SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }} + SONAR_TOKEN: ${{ inputs.sonar-api-token }} + SONAR_HOST_URL: ${{ inputs.sonar-host-url }} + LEGACY_COV_NUM: ${{ steps.coverage-calc.outputs.coverage }} diff --git a/sonarqube-angular/coverage-calc.sh b/sonarqube-angular/coverage-calc.sh new file mode 100755 index 0000000..b94fc77 --- /dev/null +++ b/sonarqube-angular/coverage-calc.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +COVERAGE=$(python -c "import xml.etree.ElementTree as ET; \ +print(float(ET.parse('coverage.xml').getroot().attrib['line-rate']) * 100)") + +echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT +echo "legacy_coverage=$COVERAGE" >> $GITHUB_OUTPUT diff --git a/sonarqube-angular/quality-gates-sonarqube.sh b/sonarqube-angular/quality-gates-sonarqube.sh new file mode 100755 index 0000000..3cb5c5f --- /dev/null +++ b/sonarqube-angular/quality-gates-sonarqube.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +PROJECT_RESPONSE=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/get_by_project?project=$SONAR_PROJECT_KEY") + +QUALITY_GATE_NAME=$(echo "$PROJECT_RESPONSE" | jq -r '.qualityGate.name') +QUALITY_GATE_NAME=$(echo "$QUALITY_GATE_NAME" | jq -sRr @uri) + +echo "Quality Gate Name: $QUALITY_GATE_NAME" + +GATE_RESPONSE=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/show?name=$QUALITY_GATE_NAME") + +NEW_COV_CONDITION_ID=$(echo "$GATE_RESPONSE" | jq -r '.conditions[] | select(.metric=="coverage") | .id') +CURRENT_NEW_COV=$(echo "$GATE_RESPONSE" | jq -r '.conditions[] | select(.metric=="coverage") | .error') + +if [ -n "$NEW_COV_CONDITION_ID" ]; then + CURRENT_NEW_COV_NUM=$(echo "$CURRENT_NEW_COV" | sed 's/[^0-9.]*//g') + + if (( $(echo "$LEGACY_COV_NUM > $CURRENT_NEW_COV_NUM" | bc -l) )); then + if (( $(echo "$LEGACY_COV_NUM > 80" | bc -l) )); then + echo "Legacy coverage ($LEGACY_COV_NUM%) > 80%, updating coverage threshold to 80%" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/update_condition" \ + -d "id=$NEW_COV_CONDITION_ID&metric=coverage&op=LT&error=80" + else + echo "Updating coverage threshold from $CURRENT_NEW_COV to $LEGACY_COV_NUM%" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/update_condition" \ + -d "id=$NEW_COV_CONDITION_ID&metric=coverage&op=LT&error=$LEGACY_COV_NUM" + fi + else + echo "Legacy coverage ($LEGACY_COV_NUM%) not greater than current coverage ($CURRENT_NEW_COV), keeping existing configuration" + fi +else + echo "Criando nova condição para coverage" + curl -u "$SONAR_TOKEN:" -X POST \ + "$SONAR_HOST_URL/api/qualitygates/create_condition" \ + -d "gateName=$QUALITY_GATE_NAME&metric=coverage&op=LT&error=$LEGACY_COV_NUM" +fi diff --git a/sonarqube-angular/sonarqube-status.sh b/sonarqube-angular/sonarqube-status.sh new file mode 100755 index 0000000..7c2d912 --- /dev/null +++ b/sonarqube-angular/sonarqube-status.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +sleep 15 +SONAR_STATUS=$(curl -s -u "$SONAR_TOKEN:" \ +"$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$SONAR_PROJECT_KEY") + +# Extract overall status +STATUS=$(echo "$SONAR_STATUS" | jq -r '.projectStatus.status') + +# Process failing conditions +echo "SonarQube Quality Gate Status: $STATUS" +if [ "$STATUS" != "OK" ]; then + echo "=== Failing Conditions ===" + echo "$SONAR_STATUS" | jq -r '.projectStatus.conditions[] | select(.status != "OK") | "Metric: \(.metricKey) | Threshold: \(.errorThreshold) | Actual: \(.actualValue)"' + + echo "status=$STATUS" >> $GITHUB_OUTPUT + echo "::error::Quality Gate failed with status: $STATUS" + exit 1 +fi + +echo "status=$STATUS" >> $GITHUB_OUTPUT +echo "Quality Gate passed successfully!" From 093cee64b755cec1e4281e2b11bfa485238aa818 Mon Sep 17 00:00:00 2001 From: Juan Ferreira Oioli <56684223+JuanOioli@users.noreply.github.com> Date: Wed, 13 Aug 2025 10:15:28 -0300 Subject: [PATCH 49/55] Adding Enviroments for Rollback Dotnet Pipeline (#19) --- rollback-environment-dotnet/action.sh | 23 +++++++++++++++++++++++ rollback-environment-dotnet/action.yml | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 rollback-environment-dotnet/action.sh create mode 100644 rollback-environment-dotnet/action.yml diff --git a/rollback-environment-dotnet/action.sh b/rollback-environment-dotnet/action.sh new file mode 100755 index 0000000..5c3d704 --- /dev/null +++ b/rollback-environment-dotnet/action.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +JWT_JWKS_PATH="https://api.dotz.com.br/accounts/api/default/" + +{ + echo "" + 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-prd.yaml tmpfile > merged_temp.yaml +awk ' + BEGIN { FS=": " } + !/^[[:space:]]*$/ && !/^#/ { + key = $1 + if (!seen[key]) { + print + seen[key] = 1 + } + } +' merged_temp.yaml > ./envs/env-prd.yaml +rm tmpfile merged_temp.yaml diff --git a/rollback-environment-dotnet/action.yml b/rollback-environment-dotnet/action.yml new file mode 100644 index 0000000..0f01772 --- /dev/null +++ b/rollback-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 }} From 3dd7dacf4061a53aee6c61ad6ef959dbea3e073e Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Tue, 26 Aug 2025 13:47:00 -0300 Subject: [PATCH 50/55] Feat: Adding Approvers to Slack msg on GMUD --- gmud-creator/action.yml | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index 8365f67..4330408 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -89,6 +89,46 @@ runs: core.setOutput('pr_url', context.payload.pull_request.html_url); core.setOutput('tested', tested); + - name: Get PR Approvers + id: get-approvers + uses: actions/github-script@v6 + with: + script: | + const { owner, repo } = context.repo; + const pr_number = context.payload.pull_request.number; + + const reviews = await github.rest.pulls.listReviews({ + owner, + repo, + pull_number: pr_number + }); + + const approverMap = new Map(); + reviews.data.forEach(review => { + if (review.state === 'APPROVED') { + approverMap.set(review.user.login, { + username: review.user.login, + avatar_url: review.user.avatar_url, + submitted_at: review.submitted_at + }); + } else if (review.state === 'CHANGES_REQUESTED' || review.state === 'DISMISSED') { + approverMap.delete(review.user.login); + } + }); + + const approvers = Array.from(approverMap.values()) + .sort((a, b) => new Date(a.submitted_at) - new Date(b.submitted_at)); + + let approversList = ''; + if (approvers.length > 0) { + approversList = approvers.map(approver => `• @${approver.username}`).join('\\n'); + } else { + approversList = '• _Nenhum approval encontrado_'; + } + + core.setOutput('approvers_list', approversList); + core.setOutput('approvers_count', approvers.length.toString()); + - name: Create GMUD via API shell: bash env: @@ -257,6 +297,19 @@ runs: "text": "*Descrição:*\n${{ steps.extract-data.outputs.summary }}" } }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Responsáveis:*\n• *Dev:* ${{ steps.extract-data.outputs.dev }}\n• *TL:* ${{ steps.extract-data.outputs.tl }}\n• *Team:* ${{ steps.extract-data.outputs.team }}" + }, + { + "type": "mrkdwn", + "text": "*Aprovadores (${{ steps.get-approvers.outputs.approvers_count }}):*\n${{ steps.get-approvers.outputs.approvers_list }}" + } + ] + }, { "type": "divider" }, From 353749c815de135bca832f31725ba195db7ba049 Mon Sep 17 00:00:00 2001 From: Juan Ferreira Oioli <56684223+JuanOioli@users.noreply.github.com> Date: Tue, 9 Sep 2025 08:11:22 -0300 Subject: [PATCH 51/55] Adding action to add envs on gcp images (#21) --- bake-apm-service-version/action.sh | 46 +++++++++++++++++++++++++++++ bake-apm-service-version/action.yml | 29 ++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 bake-apm-service-version/action.sh create mode 100644 bake-apm-service-version/action.yml diff --git a/bake-apm-service-version/action.sh b/bake-apm-service-version/action.sh new file mode 100755 index 0000000..c6c3be7 --- /dev/null +++ b/bake-apm-service-version/action.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Resolve project ID: prefer input, else gcloud config +PROJECT_ID_RESOLVED="${PROJECT_ID:-}" +if [[ -z "$PROJECT_ID_RESOLVED" ]]; then + PROJECT_ID_RESOLVED="$(gcloud config get-value project 2>/dev/null || true)" +fi + +if [[ -z "$PROJECT_ID_RESOLVED" || "$PROJECT_ID_RESOLVED" == "(unset)" ]]; then + echo "Could not determine GCP project from gcloud config. Ensure auth step set the project, or pass project_id input." + exit 1 +fi + +if [[ -z "${GCP_REGION:-}" ]]; then + echo "Input gcp_region is required" + exit 1 +fi + +if [[ -z "${REPOSITORY_NAME:-}" ]]; then + echo "Input repository_name is required" + exit 1 +fi + +if [[ -z "${TAG_VERSION:-}" ]]; then + echo "Input tag_version is required" + exit 1 +fi + +IMAGE_URL="${GCP_REGION}-docker.pkg.dev/${PROJECT_ID_RESOLVED}/${PROJECT_ID_RESOLVED}/${REPOSITORY_NAME}:${GITHUB_SHA}" +TMPDIR="$(mktemp -d)" +trap 'rm -rf "$TMPDIR"' EXIT + +echo "Baking ELASTIC_APM_SERVICE_VERSION into image: $IMAGE_URL" + +# Build a tiny wrapper image setting ELASTIC_APM_SERVICE_VERSION, using the resolved base image +cat > "$TMPDIR/Dockerfile" << EOF +FROM ${IMAGE_URL} +ENV ELASTIC_APM_SERVICE_VERSION=${TAG_VERSION} +EOF + +# Build and push to the same tag so Terraform deploys this exact image +gcloud builds submit --tag "$IMAGE_URL" "$TMPDIR" + +echo "Successfully built and pushed: $IMAGE_URL" + diff --git a/bake-apm-service-version/action.yml b/bake-apm-service-version/action.yml new file mode 100644 index 0000000..02c6d3c --- /dev/null +++ b/bake-apm-service-version/action.yml @@ -0,0 +1,29 @@ +name: Bake APM Service Version +description: Build and push an image that sets ELASTIC_APM_SERVICE_VERSION using Cloud Build + +inputs: + gcp_region: + required: true + description: GCP region, e.g., us-central1 + repository_name: + required: true + description: Artifact Registry repository name + tag_version: + required: true + description: Value for ELASTIC_APM_SERVICE_VERSION + project_id: + required: false + description: Optional GCP project ID (overrides gcloud config) + +runs: + using: composite + steps: + - name: Bake ELASTIC_APM_SERVICE_VERSION into image tag + shell: bash + run: ${{ github.action_path }}/action.sh + env: + GCP_REGION: ${{ inputs.gcp_region }} + REPOSITORY_NAME: ${{ inputs.repository_name }} + TAG_VERSION: ${{ inputs.tag_version }} + PROJECT_ID: ${{ inputs.project_id }} + From c97b838c45255d61b371abc90af53404f88ff2bc Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Mon, 10 Nov 2025 14:57:24 -0300 Subject: [PATCH 52/55] Feat: Improve JSON of GMUD action --- gmud-creator/action.yml | 58 +++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index 4330408..efcb685 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -96,13 +96,13 @@ runs: script: | const { owner, repo } = context.repo; const pr_number = context.payload.pull_request.number; - + const reviews = await github.rest.pulls.listReviews({ owner, repo, pull_number: pr_number }); - + const approverMap = new Map(); reviews.data.forEach(review => { if (review.state === 'APPROVED') { @@ -115,17 +115,17 @@ runs: approverMap.delete(review.user.login); } }); - + const approvers = Array.from(approverMap.values()) .sort((a, b) => new Date(a.submitted_at) - new Date(b.submitted_at)); - + let approversList = ''; if (approvers.length > 0) { approversList = approvers.map(approver => `• @${approver.username}`).join('\\n'); } else { approversList = '• _Nenhum approval encontrado_'; } - + core.setOutput('approvers_list', approversList); core.setOutput('approvers_count', approvers.length.toString()); @@ -262,13 +262,22 @@ runs: exit 1 fi - - name: Send GMUD payload notification - uses: archive/github-actions-slack@v2.9.0 - with: - slack-bot-user-oauth-access-token: ${{ inputs.slack_bot_user_oauth_access_token }} - slack-channel: ${{ inputs.slack_channel }} - slack-blocks: | - [ + - name: Build Slack blocks payload + id: build-slack-blocks + shell: bash + run: | + jq -n \ + --arg repo "${{ github.repository }}" \ + --arg change_type "${{ steps.extract-data.outputs.change_type }}" \ + --arg summary "${{ steps.extract-data.outputs.summary }}" \ + --arg dev "${{ steps.extract-data.outputs.dev }}" \ + --arg tl "${{ steps.extract-data.outputs.tl }}" \ + --arg team "${{ steps.extract-data.outputs.team }}" \ + --arg approvers_count "${{ steps.get-approvers.outputs.approvers_count }}" \ + --arg approvers_list "${{ steps.get-approvers.outputs.approvers_list }}" \ + --arg gmud_id "${{ steps.glpi-id.outputs.GMUD_ID }}" \ + --arg pr_url "${{ steps.extract-data.outputs.pr_url }}" \ + '[ { "type": "header", "text": { @@ -282,11 +291,11 @@ runs: "fields": [ { "type": "mrkdwn", - "text": "*Repositório:*\n${{ github.repository }}" + "text": "*Repositório:*\n" + $repo }, { "type": "mrkdwn", - "text": "*Tipo de Mudança:*\n${{ steps.extract-data.outputs.change_type }}" + "text": "*Tipo de Mudança:*\n" + $change_type } ] }, @@ -294,7 +303,7 @@ runs: "type": "section", "text": { "type": "mrkdwn", - "text": "*Descrição:*\n${{ steps.extract-data.outputs.summary }}" + "text": "*Descrição:*\n" + $summary } }, { @@ -302,11 +311,11 @@ runs: "fields": [ { "type": "mrkdwn", - "text": "*Responsáveis:*\n• *Dev:* ${{ steps.extract-data.outputs.dev }}\n• *TL:* ${{ steps.extract-data.outputs.tl }}\n• *Team:* ${{ steps.extract-data.outputs.team }}" + "text": "*Responsáveis:*\n• *Dev:* " + $dev + "\n• *TL:* " + $tl + "\n• *Team:* " + $team }, { "type": "mrkdwn", - "text": "*Aprovadores (${{ steps.get-approvers.outputs.approvers_count }}):*\n${{ steps.get-approvers.outputs.approvers_list }}" + "text": "*Aprovadores (" + $approvers_count + ") :*\n" + $approvers_list } ] }, @@ -323,7 +332,7 @@ runs: "text": "Abrir no GLPI", "emoji": true }, - "url": "https://suporte.dotz.com.br/front/change.form.php?id=${{ steps.glpi-id.outputs.GMUD_ID }}", + "url": "https://suporte.dotz.com.br/front/change.form.php?id=" + $gmud_id, "style": "primary" }, { @@ -333,8 +342,17 @@ runs: "text": "Ver PR no GitHub", "emoji": true }, - "url": "${{ steps.extract-data.outputs.pr_url }}" + "url": $pr_url } ] } - ] \ No newline at end of file + ]' > slack_blocks.json + + echo "blocks=$(jq -c . slack_blocks.json)" >> "$GITHUB_OUTPUT" + + - name: Send GMUD payload notification + uses: archive/github-actions-slack@v2.9.0 + with: + slack-bot-user-oauth-access-token: ${{ inputs.slack_bot_user_oauth_access_token }} + slack-channel: ${{ inputs.slack_channel }} + slack-blocks: ${{ steps.build-slack-blocks.outputs.blocks }} \ No newline at end of file From e687e3c38441e51dbaa865aebf39ab549fdf74c3 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Mon, 10 Nov 2025 15:10:50 -0300 Subject: [PATCH 53/55] PR Adjusts --- gmud-creator/action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index efcb685..d76de8d 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -291,11 +291,11 @@ runs: "fields": [ { "type": "mrkdwn", - "text": "*Repositório:*\n" + $repo + "text": ("*Repositório:*\n" + $repo) }, { "type": "mrkdwn", - "text": "*Tipo de Mudança:*\n" + $change_type + "text": ("*Tipo de Mudança:*\n" + $change_type) } ] }, @@ -303,7 +303,7 @@ runs: "type": "section", "text": { "type": "mrkdwn", - "text": "*Descrição:*\n" + $summary + "text": ("*Descrição:*\n" + $summary) } }, { @@ -311,11 +311,11 @@ runs: "fields": [ { "type": "mrkdwn", - "text": "*Responsáveis:*\n• *Dev:* " + $dev + "\n• *TL:* " + $tl + "\n• *Team:* " + $team + "text": ("*Responsáveis:*\n• *Dev:* " + $dev + "\n• *TL:* " + $tl + "\n• *Team:* " + $team) }, { "type": "mrkdwn", - "text": "*Aprovadores (" + $approvers_count + ") :*\n" + $approvers_list + "text": ("*Aprovadores (" + $approvers_count + "):*\n" + $approvers_list) } ] }, @@ -332,7 +332,7 @@ runs: "text": "Abrir no GLPI", "emoji": true }, - "url": "https://suporte.dotz.com.br/front/change.form.php?id=" + $gmud_id, + "url": ("https://suporte.dotz.com.br/front/change.form.php?id=" + $gmud_id), "style": "primary" }, { From bfd0ded7433d50d5df1ceb54a789124dcc003824 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Mon, 10 Nov 2025 15:19:35 -0300 Subject: [PATCH 54/55] PR Adjusts --- gmud-creator/action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index d76de8d..a49f359 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -348,7 +348,11 @@ runs: } ]' > slack_blocks.json - echo "blocks=$(jq -c . slack_blocks.json)" >> "$GITHUB_OUTPUT" + BLOCKS=$(jq -c . slack_blocks.json) + BLOCKS=${BLOCKS//'%'/'%25'} + BLOCKS=${BLOCKS//$'\n'/'%0A'} + BLOCKS=${BLOCKS//$'\r'/'%0D'} + echo "blocks=$BLOCKS" >> "$GITHUB_OUTPUT" - name: Send GMUD payload notification uses: archive/github-actions-slack@v2.9.0 From f9bd3f313080459c3f731138cfd63be502ebcac9 Mon Sep 17 00:00:00 2001 From: Alexandre Macedo Date: Mon, 10 Nov 2025 15:21:41 -0300 Subject: [PATCH 55/55] PR Adjusts --- gmud-creator/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gmud-creator/action.yml b/gmud-creator/action.yml index a49f359..389aed8 100644 --- a/gmud-creator/action.yml +++ b/gmud-creator/action.yml @@ -359,4 +359,4 @@ runs: with: slack-bot-user-oauth-access-token: ${{ inputs.slack_bot_user_oauth_access_token }} slack-channel: ${{ inputs.slack_channel }} - slack-blocks: ${{ steps.build-slack-blocks.outputs.blocks }} \ No newline at end of file + slack-blocks: ${{ steps.build-slack-blocks.outputs.blocks }}