Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release] Stage to Main #12

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/release-notification.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: release-notification
name: On PR Closed

on:
pull_request:
Expand All @@ -18,15 +18,13 @@ jobs:
runs-on: ubuntu-latest
environment: cc-test-release
env:
PR_BODY: ${{ github.event.pull_request.body }}
EVENT_PR: ${{ github.event.pull_request }}
steps:
- name: Print Body
run: echo "$PR_BODY"
- name: Checkout repository
uses: actions/checkout@v4
- name: Sending Notification - Slack
uses: actions/github-script@v7
with:
script: |
const sendSlackMessage = require('./.github/workflows/send-slack.js')
sendSlackMessage(process.env.PR_BODY,process.env.CC_SLACK_WEBHOOK)
sendSlackMessage(process.env.EVENT_PR,process.env.CC_SLACK_WEBHOOK)
11 changes: 0 additions & 11 deletions .github/workflows/send-slack.js

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/src/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function convertMarkdownToSlackFormat(markdown) {
// Convert headings
markdown = markdown.replace(/^(#+) (.*$)/gim, "*$2*");
// Convert bold text
markdown = markdown.replace(/\*\*(.*?)\*\*/gim, "*$1*");
// Convert italic text
markdown = markdown.replace(/\*(.*?)\*/gim, "_$1_");
// Convert inline code
markdown = markdown.replace(/`([^`]+)`/g, "```$1```");
// Convert block quotes
markdown = markdown.replace(/^> (.*$)/gim, "_$1_");
// Convert unordered lists
markdown = markdown.replace(/^\s*[-+*]\s+(.*$)/gim, "• $1");
// Convert ordered lists
markdown = markdown.replace(/^\s*\d+\.\s+(.*$)/gim, "1. $1");
// Convert newlines to break lines
markdown = markdown.replace(/\n/g, "\n");

return markdown.trim();
}

module.exports = {
convertMarkdownToSlackFormat,
};
18 changes: 18 additions & 0 deletions .github/workflows/src/send-slack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { convertMarkdownToSlackFormat } = require("./helpers");

const sendSlackMessage = async (event_pr, slack_webhook_url) => {
const { number, html_url, title, body } = event_pr;

const text = `:rocket: *Production Release*\n*Title:* ${title} | <${html_url}|#${number}>\n*PR Description:* ${convertMarkdownToSlackFormat(
body
)}`;
console.log("text", text);

const result = await fetch(slack_webhook_url, {
method: "POST",
body: JSON.stringify({ text }),
}).catch(console.error);
return result;
};

module.exports = sendSlackMessage;
Loading