Skip to content

Commit

Permalink
format and body undefined error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jun3453 committed Mar 4, 2020
1 parent 755b246 commit 533fff3
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions SlackPrNotification.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
import axios from 'axios';

const url : string = process.env.SLACK_WEBHOOK_URL;
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 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;
const baseBranchName : string = process.env.PULL_REQUEST_BASE_BRANCH_NAME;
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 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;
const baseBranchName: string = process.env.PULL_REQUEST_BASE_BRANCH_NAME;

const sendHereMention : string = process.env.IS_SEND_HERE_MENTION ? "<!here>\n" : "";
const sendHereMention: string = process.env.IS_SEND_HERE_MENTION ? "<!here>\n" : "";

const message : Object = {
blocks : [
const message: Object = {
blocks: [
{
type : "section",
text : {
type : "mrkdwn",
text : sendHereMention + "*<" + prUrl + "|" + prTitle + ">*",
type: "section",
text: {
type: "mrkdwn",
text: sendHereMention + "*<" + prUrl + "|" + prTitle + ">*",
},
accessory : {
type : "image",
image_url : authorIconUrl,
alt_text : "github icon",
accessory: {
type: "image",
image_url: authorIconUrl,
alt_text: "github icon",
},
fields : [
fields: [
{
type : "mrkdwn",
text : "*Author*\n" + authorName,
type: "mrkdwn",
text: "*Author*\n" + authorName,
},
{
type : "mrkdwn",
text : "*Base branch*\n" + baseBranchName,
type: "mrkdwn",
text: "*Base branch*\n" + baseBranchName,
},
{
type : "mrkdwn",
text : "*Pull request number*\n#" + prNum,
type: "mrkdwn",
text: "*Pull request number*\n#" + prNum,
},
{
type : "mrkdwn",
text : "*Compare branch*\n" + compareBranchName,
type: "mrkdwn",
text: "*Compare branch*\n" + compareBranchName,
},
],
},
{
type : "section",
text : {
type : "plain_text",
text : prBody,
emoji : true,
type: "section",
text: {
type: "plain_text",
text: `${prBody}`,
emoji: true,
},
},
},
]
};

Expand Down

0 comments on commit 533fff3

Please sign in to comment.