Skip to content
Merged
Changes from all commits
Commits
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
86 changes: 83 additions & 3 deletions gmud-creator/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -118,6 +118,8 @@ runs:
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>
Expand All @@ -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 }}" \
Expand Down Expand Up @@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The GitHub Action archive/github-actions-slack is archived and no longer maintained. Using it can pose a security risk and lead to future compatibility issues. It's highly recommended to migrate to the officially supported Slack action, slackapi/slack-github-action.

with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_NOBOT_TOKEN }}
slack-channel: 'C093VDRV5CP'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Slack channel ID is hardcoded, which limits the reusability of this action. It's better to define this as an input so that different workflows can specify different channels.

        slack-channel: ${{ inputs.slack_channel_id }}

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