Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3081bec
feat: criação de nova action
May 7, 2024
15c8a56
ajuste na action
May 7, 2024
3252d2b
add permission
May 7, 2024
f92e9b9
correção APPNAME
May 7, 2024
05f964e
add platform
May 8, 2024
ec6616e
ajuste do nome
May 8, 2024
f285d2c
adicionar environment
May 8, 2024
62476a2
ajuste nome da variavel
May 8, 2024
b7dfebc
ajuste url elk uat
May 8, 2024
e81b471
removendo env
May 8, 2024
741ee8b
adicionar aspas e remover escapes
May 9, 2024
eab16c6
adicionar espaço
May 9, 2024
8d6fef7
ajuste
May 9, 2024
0133787
trazer variaveis para o projeto
May 9, 2024
56f5940
remover entradas não usadas
May 9, 2024
1482813
Merge pull request #1 from DotzInc/setenv
gabriellavor May 10, 2024
b164ef8
add env qa (#2)
gabriellavor Jun 13, 2024
15fa2fd
Feat: modifying elk url get by workflow input
JuanOioli May 6, 2025
a993ef1
Merge pull request #3 from DotzInc/feat/elk-url-from-secret
JuanOioli May 6, 2025
6011994
feat: add sonarqube
diego-dm-morais Jun 26, 2025
f3c62fb
feat: add sonarqube
diego-dm-morais Jun 26, 2025
ecb441b
feat: add sonarqube
diego-dm-morais Jun 26, 2025
7ad944d
feat: add sonarqube
diego-dm-morais Jun 26, 2025
d17c006
feat: add sonarqube
diego-dm-morais Jun 26, 2025
c153bfa
feat: add sonarqube
diego-dm-morais Jun 26, 2025
6f18d7e
feat: add sonarqube
diego-dm-morais Jun 26, 2025
2e9edaf
feat: add sonarqube
diego-dm-morais Jun 26, 2025
fe11bed
feat: add sonarqube
diego-dm-morais Jun 26, 2025
b5f20d7
feat: add sonarqube
diego-dm-morais Jun 26, 2025
da59404
feat: add sonarqube
diego-dm-morais Jun 26, 2025
9127dbf
feat: add sonarqube
diego-dm-morais Jun 26, 2025
0751bb5
feat: add sonarqube
diego-dm-morais Jun 26, 2025
1216143
Merge pull request #4 from DotzInc/feat/update-code
diego-dm-morais Jun 26, 2025
fe445ed
feat: add sonarqube (#5)
diego-dm-morais Jun 26, 2025
39e675c
First commit to test
Jun 26, 2025
a49b9b1
feat: update sonarqube (#6)
diego-dm-morais Jun 27, 2025
3a9473e
feat: update pipeline test (#7)
diego-dm-morais Jun 27, 2025
fe44d03
Feat: Creating Bump Tag Action (#8)
JuanOioli Jun 30, 2025
940d6db
Removing if need run to workflow
Jul 2, 2025
4a75a77
Fix: field of function
Jul 2, 2025
4610bd5
Merge pull request #9 from DotzInc/feat/adding-gmud-creator-action
alexandremac Jul 2, 2025
3fab3d4
Fix: Regex to get responsible
Jul 3, 2025
7ff1565
Merge pull request #10 from DotzInc/fix-regex
alexandremac Jul 3, 2025
7ce6113
Adding Slack Test channel
Jul 3, 2025
ce083e9
Merge pull request #11 from DotzInc/feat/update-service-name
alexandremac Jul 3, 2025
21ada32
Adding vars inherit secrets
Jul 3, 2025
8e53c43
Fix: variables pattern
Jul 3, 2025
563498a
Merge pull request #12 from DotzInc/fix/adding-secrets-to-slack
alexandremac Jul 3, 2025
9850630
feat: add sonarqube dot net (#13)
diego-dm-morais Jul 3, 2025
ae27f1b
feat: add sonarqube
diego-dm-morais Jul 3, 2025
8d16bb4
feat: add sonarqube
diego-dm-morais Jul 4, 2025
a9693c8
feat: add sonarqube
diego-dm-morais Jul 4, 2025
83a67e7
feat: add sonarqube
diego-dm-morais Jul 4, 2025
595aaba
feat: add sonarqube
diego-dm-morais Jul 4, 2025
995edc7
feat: add sonarqube
diego-dm-morais Jul 4, 2025
7c99a5e
feat: add sonarqube
diego-dm-morais Jul 4, 2025
81097a5
feat: add sonarqube
diego-dm-morais Jul 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions environment-dotnet/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

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

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

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

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

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

runs:
using: composite
steps:
- name: Create Env Test
shell: bash
run: ${{ github.action_path }}/action.sh
287 changes: 287 additions & 0 deletions gmud-creator/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
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
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"
steps:
- name: Validate GLPI_API_URL format
shell: bash
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
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*\\[(.*?)\\]`, 'i');
const match = pbody.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 tested = /-\s\[x\]\s\*\*Confirmo\*\*/i.test(prBody) ? 'Sim' : 'Não';

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('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);
core.setOutput('tested', tested);

- name: Create GMUD via API
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 <<EOF
<p><strong>Confirmo que foi testado em ambiente de homologação:</strong></p>
<p>${{ steps.extract-data.outputs.tested }}</p>
<p><strong>Contexto:</strong></p>
<p>${{ steps.extract-data.outputs.context }}</p>
<br>
<p><strong>Problema</strong>:</p>
<p>${{ steps.extract-data.outputs.problem }}</p>
<br>
<p><strong>Mudança:</strong></p>
<p>${{ steps.extract-data.outputs.change }}</p>
<br>
<p><strong>PR(s):</strong></p>
<p>${{ steps.extract-data.outputs.pr_url }}</p>
<br><br>
<p><strong>Link da task no Azure:</strong></p>
<p>${{ steps.extract-data.outputs.task_link }}</p>
<br><br>
<p><strong>Responsáveis:</strong></p>
<p>Dev: ${{ steps.extract-data.outputs.dev }}</p>
<p>TL: ${{ steps.extract-data.outputs.tl }}</p>
<p>Team: ${{ steps.extract-data.outputs.team }}</p>
<br><br>
<p><strong>Aprovador:</strong></p>
<p>${{ steps.extract-data.outputs.approver }}</p>
EOF
)

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 }}" \
--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": "<p>Merge+do+PR+após+aprovação.</p>",
"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

- 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
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-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 }}"
}
]
}
]
Loading