Skip to content

Commit

Permalink
Working on actual message
Browse files Browse the repository at this point in the history
  • Loading branch information
pingevt committed Oct 25, 2024
1 parent 475ab14 commit 65b64e4
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions .ci/scripts/pr-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ try {
// requested_reviewers: [],
// html_url
// login
// avatar_url

let descriptionTxt = "";

Expand All @@ -80,19 +81,20 @@ try {
// Date.
// const date = new Date(Date.parse(CONTEXT_GITHUB.event.pull_request.created_at));
const date = DateTime.fromISO(CONTEXT_GITHUB.event.pull_request.created_at); // DATETIME_SHORT .toLocaleString(DateTime.DATETIME_SHORT)
descriptionTxt += "created: " + date.toLocaleString(DateTime.DATETIME_SHORT) + "\r\n";
// descriptionTxt += "created: " + date.toLocaleString(DateTime.DATETIME_SHORT) + "\r\n";

// Mergable.
descriptionTxt += "mergeable: " + CONTEXT_GITHUB.event.pull_request.mergeable + "\r\n";
descriptionTxt += "mergeable_state: " + CONTEXT_GITHUB.event.pull_request.mergeable_state + "\r\n";
descriptionTxt += "rebaseable: " + CONTEXT_GITHUB.event.pull_request.rebaseable + "\r\n";
// descriptionTxt += "mergeable: " + CONTEXT_GITHUB.event.pull_request.mergeable + "\r\n";
// descriptionTxt += "mergeable_state: " + CONTEXT_GITHUB.event.pull_request.mergeable_state + "\r\n";
// descriptionTxt += "rebaseable: " + CONTEXT_GITHUB.event.pull_request.rebaseable + "\r\n";

// Commits.
descriptionTxt += "commits: " + CONTEXT_GITHUB.event.pull_request.commits + "\r\n";
// descriptionTxt += "commits: " + CONTEXT_GITHUB.event.pull_request.commits + "\r\n";

// Comments.
descriptionTxt += "comments: " + CONTEXT_GITHUB.event.pull_request.comments + "\r\n";
// descriptionTxt += "comments: " + CONTEXT_GITHUB.event.pull_request.comments + "\r\n";

descriptionTxt += ":page_facing_up: :eyes: :large_green_circle: :white_check_mark: :large_yellow_square: :fire: \r\n";

if (CONTEXT_GITHUB.event.pull_request.requested_reviewers.length > 0) {
// Review Comments.
Expand All @@ -106,6 +108,8 @@ try {





payload = buildPayload(descriptionTxt);
console.log(payload);

Expand Down Expand Up @@ -139,6 +143,7 @@ function buildPayload(statusMsg = "") {
const CONTEXT_GITHUB = JSON.parse(process.env.CONTEXT_GITHUB);

let payload = {};
payload.title = CONTEXT_GITHUB.event.pull_request.title;
payload.blocks = [];

// Title.
Expand All @@ -149,7 +154,7 @@ function buildPayload(statusMsg = "") {
titleBlock.text.emoji = true;
let t = "";
if (CONTEXT_GITHUB.event.pull_request.draft) {
t += "draft ";
t += ":page_facing_up: draft ";
}
t += "PR #" + CONTEXT_GITHUB.event.number;
t += " | " + CONTEXT_GITHUB.event.pull_request.title;
Expand All @@ -167,6 +172,23 @@ function buildPayload(statusMsg = "") {
statusBlock.text.type = "mrkdwn";
statusBlock.text.text = statusMsg;

// Context.
let contextBlock = {};
statusBlock.type = "context";
statusBlock.elements = [];
statusBlock.elements.push({
type: 'image',
image_url: CONTEXT_GITHUB.event.pull_request.user.avatar_url,
alt_text: 'User Avatar'
});
// CONTEXT_GITHUB.event.pull_request.user.avatar_url
const date = DateTime.fromISO(CONTEXT_GITHUB.event.pull_request.created_at);
statusBlock.elements.push({
type: 'mrkdwn',
text: '<' + CONTEXT_GITHUB.event.pull_request.user.html_url + '|' + CONTEXT_GITHUB.event.pull_request.user.login + '> created this PR on ' + date.toLocaleString(DateTime.DATETIME_SHORT)
});


// Action w/ link.
let actionBlock = {};
actionBlock.type = "actions";
Expand All @@ -187,6 +209,7 @@ function buildPayload(statusMsg = "") {
// Put it all together.
payload.blocks.push(titleBlock);
payload.blocks.push(divBlock);
// payload.blocks.push(statusBlock);
payload.blocks.push(statusBlock);
payload.blocks.push(actionBlock);

Expand Down

0 comments on commit 65b64e4

Please sign in to comment.