From 737efb9e9a982602470af87ddf617884c3a0bee4 Mon Sep 17 00:00:00 2001 From: junki Date: Wed, 4 Mar 2020 14:13:55 +0900 Subject: [PATCH] fix no description provided error --- SlackPrNotification.js | 112 ++++++++++++++++++++--------------------- SlackPrNotification.ts | 4 +- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/SlackPrNotification.js b/SlackPrNotification.js index a3bbdfc..90d3051 100644 --- a/SlackPrNotification.js +++ b/SlackPrNotification.js @@ -1,56 +1,56 @@ -"use strict"; -exports.__esModule = true; -var axios_1 = require("axios"); -var url = process.env.SLACK_WEBHOOK_URL; -var prNum = process.env.PULL_REQUEST_NUMBER; -var prTitle = process.env.PULL_REQUEST_TITLE; -var prUrl = process.env.PULL_REQUEST_URL; -var prBody = process.env.PULL_REQUEST_BODY; -var authorName = process.env.PULL_REQUEST_AUTHOR_NAME; -var authorIconUrl = process.env.PULL_REQUEST_AUTHOR_ICON_URL; -var compareBranchName = process.env.PULL_REQUEST_COMPARE_BRANCH_NAME; -var baseBranchName = process.env.PULL_REQUEST_BASE_BRANCH_NAME; -var sendHereMention = process.env.IS_SEND_HERE_MENTION ? "\n" : ""; -var message = { - blocks: [ - { - type: "section", - text: { - type: "mrkdwn", - text: sendHereMention + "*<" + prUrl + "|" + prTitle + ">*" - }, - accessory: { - type: "image", - image_url: authorIconUrl, - alt_text: "github icon" - }, - fields: [ - { - type: "mrkdwn", - text: "*Author*\n" + authorName - }, - { - type: "mrkdwn", - text: "*Base branch*\n" + baseBranchName - }, - { - type: "mrkdwn", - text: "*Pull request number*\n#" + prNum - }, - { - type: "mrkdwn", - text: "*Compare branch*\n" + compareBranchName - }, - ] - }, - { - type: "section", - text: { - type: "plain_text", - text: prBody, - emoji: true - } - }, - ] -}; -axios_1["default"].post(url, message); +"use strict"; +exports.__esModule = true; +var axios_1 = require("axios"); +var url = process.env.SLACK_WEBHOOK_URL; +var prNum = process.env.PULL_REQUEST_NUMBER; +var prTitle = process.env.PULL_REQUEST_TITLE; +var prUrl = process.env.PULL_REQUEST_URL; +var prBody = process.env.PULL_REQUEST_BODY || "No decription provided."; +var authorName = process.env.PULL_REQUEST_AUTHOR_NAME; +var authorIconUrl = process.env.PULL_REQUEST_AUTHOR_ICON_URL; +var compareBranchName = process.env.PULL_REQUEST_COMPARE_BRANCH_NAME; +var baseBranchName = process.env.PULL_REQUEST_BASE_BRANCH_NAME; +var sendHereMention = process.env.IS_SEND_HERE_MENTION ? "\n" : ""; +var message = { + blocks: [ + { + type: "section", + text: { + type: "mrkdwn", + text: sendHereMention + "*<" + prUrl + "|" + prTitle + ">*" + }, + accessory: { + type: "image", + image_url: authorIconUrl, + alt_text: "github icon" + }, + fields: [ + { + type: "mrkdwn", + text: "*Author*\n" + authorName + }, + { + type: "mrkdwn", + text: "*Base branch*\n" + baseBranchName + }, + { + type: "mrkdwn", + text: "*Pull request number*\n#" + prNum + }, + { + type: "mrkdwn", + text: "*Compare branch*\n" + compareBranchName + }, + ] + }, + { + type: "section", + text: { + type: "plain_text", + text: prBody, + emoji: true + } + }, + ] +}; +axios_1["default"].post(url, message); diff --git a/SlackPrNotification.ts b/SlackPrNotification.ts index c4cd707..4923348 100644 --- a/SlackPrNotification.ts +++ b/SlackPrNotification.ts @@ -5,7 +5,7 @@ const url: string = process.env.SLACK_WEBHOOK_URL; const prNum: string = process.env.PULL_REQUEST_NUMBER; const prTitle: string = process.env.PULL_REQUEST_TITLE; const prUrl: string = process.env.PULL_REQUEST_URL; -const prBody: string = process.env.PULL_REQUEST_BODY; +const prBody: string = process.env.PULL_REQUEST_BODY || "No decription provided."; const authorName: string = process.env.PULL_REQUEST_AUTHOR_NAME; const authorIconUrl: string = process.env.PULL_REQUEST_AUTHOR_ICON_URL; const compareBranchName: string = process.env.PULL_REQUEST_COMPARE_BRANCH_NAME; @@ -49,7 +49,7 @@ const message: Object = { type: "section", text: { type: "plain_text", - text: `${prBody}`, + text: prBody, emoji: true, }, },