Skip to content

Commit

Permalink
fix: Use attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashicc committed Mar 14, 2024
1 parent a442af8 commit ae62bda
Showing 1 changed file with 58 additions and 53 deletions.
111 changes: 58 additions & 53 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,68 +13,73 @@ async function run(inputs: SlackApprovalInputs, app: App): Promise<void> {
(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",
},
],
},
],
},
Expand Down

0 comments on commit ae62bda

Please sign in to comment.