Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit fa351b5

Browse files
committed
✨ colors on Pipeline pass / fail
1 parent 721b2ae commit fa351b5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bot.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ WebhookEvent.on('post', async (post: Message) => {
1717
console.log(post);
1818

1919
const regexInner = `.+(?: \\/ .+)*?(?=]\\(https:\\/\\/gitlab\\.com\\/${process.env.GITLAB_ORG_NAME.toLowerCase()}\\/[a-z\\-\\/]+\\)`;
20-
const regex = new RegExp(`(?<=\\[${process.env.GITLAB_ORG_NAME} / )${regexInner})|(?<=\\[)${regexInner}: Pipeline)`)
20+
const regex = new RegExp(`(?<=\\[${process.env.GITLAB_ORG_NAME} / )${regexInner})|(?<=\\[)${regexInner}: Pipeline)`);
2121

2222
const matches = post.embeds[0].description.match(regex);
2323

2424
if (!matches) return;
2525

26+
if (post.embeds[0].description.match(/Pipeline/)) {
27+
if (post.embeds[0].description.match(/passed/)) post.embeds[0].color = 123456;
28+
else if (post.embeds[0].description.match(/failed/)) post.embeds[0].color = 16711680;
29+
}
30+
2631
matches[0] = matches[0].replace(new RegExp(`${process.env.GITLAB_ORG_NAME} /(?: .*? \\/)* `), '');
2732

2833
const channel = (await client.channels.fetch(

0 commit comments

Comments
 (0)