From ae62bdaa2245cb643163f9571b2d8909edc85101 Mon Sep 17 00:00:00 2001 From: Takashicc <105186894+Takashicc@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:30:40 +0900 Subject: [PATCH] fix: Use attachments --- src/index.ts | 111 +++++++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 53 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4fa22583..8eda9e9f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,68 +13,73 @@ async function run(inputs: SlackApprovalInputs, app: App): Promise { (async () => { await web.chat.postMessage({ channel: inputs.channelId, - link_names: true, - blocks: [ + text: `<@${inputs.mentionTo}>`, + attachments: [ { - type: "section", - text: { - type: "mrkdwn", - text: `<@${inputs.mentionTo}>\n*GitHub Actions Approval Request*`, - }, - }, - { - type: "section", - fields: [ - { - type: "mrkdwn", - text: `*GitHub Actor:*\n${githubInfo.actor}`, - }, - { - type: "mrkdwn", - text: `*Repos:*\n${githubInfo.serverUrl}/${githubInfo.repo}`, - }, - { - type: "mrkdwn", - text: `*Actions URL:*\n${githubInfo.actionUrl}`, - }, + blocks: [ { - type: "mrkdwn", - text: `*GITHUB_RUN_ID:*\n${githubInfo.runId}`, - }, - { - type: "mrkdwn", - text: `*Workflow:*\n${githubInfo.workflow}`, - }, - { - type: "mrkdwn", - text: `*RunnerOS:*\n${githubInfo.runnerOS}`, + type: "section", + text: { + type: "mrkdwn", + text: "*GitHub Action Approval Request*", + }, }, ], }, { - type: "actions", - elements: [ + color: "#00FF00", + blocks: [ { - type: "button", - text: { - type: "plain_text", - emoji: true, - text: "Approve", - }, - style: "primary", - value: "approve", - action_id: "slack-approval-approve", + type: "section", + fields: [ + { + type: "mrkdwn", + text: `*Repository:* ${githubInfo.serverUrl}/${githubInfo.repo}` + }, + { + type: "mrkdwn", + text: `*Action URL:* ${githubInfo.actionUrl}` + }, + { + type: "mrkdwn", + text: `*Workflow Name:* ${githubInfo.workflow}` + }, + { + type: "mrkdwn", + text: `*Runner OS:* ${githubInfo.runnerOS}` + }, + ], }, + ] + }, + { + blocks: [ { - type: "button", - text: { - type: "plain_text", - emoji: true, - text: "Reject", - }, - style: "danger", - value: "reject", - action_id: "slack-approval-reject", + type: "actions", + elements: [ + { + type: "button", + text: { + type: "plain_text", + emoji: true, + text: "Approve", + }, + style: "primary", + value: "approve", + action_id: "slack-approval-approve", + }, + { + type: "button", + text: { + type: "plain_text", + emoji: true, + text: "Reject", + }, + style: "danger", + value: "reject", + action_id: "slack-approval-reject", + }, + ], }, ], },