From e15e4aeff8ddb75bb4cd145923fd4cbbf3910dd2 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:27:54 +0100 Subject: [PATCH] Handle much more events --- index.js | 11 +++++-- templates/code_scanning_alert.js | 36 +++++++++++----------- templates/create.js | 5 +-- templates/delete.js | 4 +-- templates/deploy_key.js | 4 +-- templates/deployment.js | 3 +- templates/deployment_protection_rule.js | 2 +- templates/fork.js | 5 +-- templates/issue_comment.js | 15 +++++---- templates/label.js | 9 ++++-- templates/meta.js | 1 + templates/personal_access_token_request.js | 21 +++++++------ templates/public.js | 4 +-- templates/push.js | 4 +-- templates/release.js | 35 ++++++++++----------- templates/repository_import.js | 1 + templates/security_advisory.js | 19 +++++++----- templates/security_and_analysis.js | 9 ++++-- templates/sponsorship.js | 20 ++++++------ templates/star.js | 16 +++++----- templates/status.js | 4 +-- templates/workflow_job.js | 4 +-- templates/workflow_run.js | 22 ++++++++----- 23 files changed, 145 insertions(+), 109 deletions(-) diff --git a/index.js b/index.js index c66045e..3ae0e29 100644 --- a/index.js +++ b/index.js @@ -256,11 +256,18 @@ const hookFunc = async (req, res) => { message = JSON.stringify(require(path.join(__dirname, "templates", githubEventSani + ".js")).find(msg => msg.action == action) || require(path.join(__dirname, "templates", githubEventSani + ".js"))[0]) } + // Handling {{ count(array) }} + message = message.replace(/{{ ?count\(([^}]+)\) ?}}/gi, (match, group) => { + const parts = group.split(".") + let obj = data + for (const part of parts) obj = obj[part] + return obj.length + }) + const recursiveFunc = (obj, currentPath = "") => { for (const property in obj) { if (typeof obj[property] == "object") recursiveFunc(obj[property], currentPath + property + ".") - // Possible syntax: {sender.login} or {{ sender.login }} or something in between - else message = message.replace(new RegExp("{{? ?" + currentPath + property + " ?}}?", "gi"), obj[property]) + else message = message.replace(new RegExp("{{ ?" + currentPath + property + " ?}}", "gi"), obj[property]) } } recursiveFunc(data) diff --git a/templates/code_scanning_alert.js b/templates/code_scanning_alert.js index dfc5d59..ed1e36b 100644 --- a/templates/code_scanning_alert.js +++ b/templates/code_scanning_alert.js @@ -8,9 +8,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `code_scanning_alert` (`appeared_in_branch`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ repository.name }}] Code scanning alert **#{{ alert.number }}** appeared in {{ ref }}", + url: "{{ alert.html_url }}", + color: color("red") }] },{ action: "closed_by_user", @@ -19,9 +19,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `code_scanning_alert` (`closed_by_user`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ repository.name }}] Code scanning alert **#{{ alert.number }}** closed as {{ alert.dismissed_reason }}", + url: "{{ alert.html_url }}", + color: color("red") }] },{ action: "created", @@ -30,9 +30,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `code_scanning_alert` (`created`)", - url: "{{ repository.html_url }}", - color: color("green") + title: "[{{ repository.name }}] Code scanning alert **#{{ alert.number }}** created", + url: "{{ alert.html_url }}", + color: color("red") }] },{ action: "fixed", @@ -41,9 +41,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `code_scanning_alert` (`fixed`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ repository.name }}] Code scanning alert **#{{ alert.number }}** fixed", + url: "{{ alert.html_url }}", + color: color("green") }] },{ action: "reopened", @@ -52,9 +52,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `code_scanning_alert` (`reopened`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ repository.name }}] Code scanning alert **#{{ alert.number }}** reopened", + url: "{{ alert.html_url }}", + color: color("red") }] },{ action: "reopened_by_user", @@ -63,9 +63,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `code_scanning_alert` (`reopened_by_user`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ repository.name }}] Code scanning alert **#{{ alert.number }}** reopened", + url: "{{ alert.html_url }}", + color: color("red") }] } ] diff --git a/templates/create.js b/templates/create.js index b4b06ba..50ce009 100644 --- a/templates/create.js +++ b/templates/create.js @@ -7,9 +7,10 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `create`", + title: "[{{ repository.name }}] Git {{ ref_type }} created", url: "{{ repository.html_url }}", - color: color("black") + description: "```{{ ref }}```", + color: color("darkGreen") }] } ] diff --git a/templates/delete.js b/templates/delete.js index 0477924..6c2f2af 100644 --- a/templates/delete.js +++ b/templates/delete.js @@ -7,10 +7,10 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] Git {{ ref_type }} deleted", + title: "[{{ repository.name }}] Git {{ ref_type }} deleted", url: "{{ repository.html_url }}", description: "```{{ ref }}```", - color: color("black") + color: color("darkRed") }] } ] diff --git a/templates/deploy_key.js b/templates/deploy_key.js index c501622..88b3ba8 100644 --- a/templates/deploy_key.js +++ b/templates/deploy_key.js @@ -8,7 +8,7 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.full_name }}] Deploy key **{{ key.title }}** created", + title: "[{{ repository.name }}] Deploy key **{{ key.title }}** created", url: "{{ repository.html_url }}", color: color("green") }] @@ -19,7 +19,7 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.full_name }}] Deploy key **{{ key.title }}** deleted", + title: "[{{ repository.name }}] Deploy key **{{ key.title }}** deleted", url: "{{ repository.html_url }}", color: color("red") }] diff --git a/templates/deployment.js b/templates/deployment.js index 1d9371e..5a9d543 100644 --- a/templates/deployment.js +++ b/templates/deployment.js @@ -11,8 +11,7 @@ module.exports = [ title: "[{{ repository.name }}:{{ repository.default_branch }}] Deployment created", url: "{{ deployment.url }}", description: "{{ deployment.description }}\n\n{{ deployment.environment }}", - color: color("green"), - timestamp: "{{ deployment.created_at }}" + color: color("green") }] } ] diff --git a/templates/deployment_protection_rule.js b/templates/deployment_protection_rule.js index 156560b..5649dd1 100644 --- a/templates/deployment_protection_rule.js +++ b/templates/deployment_protection_rule.js @@ -8,7 +8,7 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] Deployment protection rule requested", + title: "[{{ repository.name }}] Deployment protection rule requested by {{ event }}", url: "{{ repository.html_url }}", color: color("black") }] diff --git a/templates/fork.js b/templates/fork.js index 864cf2c..6c53830 100644 --- a/templates/fork.js +++ b/templates/fork.js @@ -5,11 +5,12 @@ module.exports = [ embeds: [{ author: { name: "{{ sender.login }}", - icon_url: "{{ sender.avatar_url }}" + icon_url: "{{ sender.avatar_url }}", + url: "{{ sender.html_url }}" }, title: "[{{ forkee.full_name }}] Fork created", url: "{{ forkee.html_url }}", - color: color("black") + color: color("magenta") }] } ] diff --git a/templates/issue_comment.js b/templates/issue_comment.js index 8da3af0..297706b 100644 --- a/templates/issue_comment.js +++ b/templates/issue_comment.js @@ -8,8 +8,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] Issue comment created", - url: "{{ repository.html_url }}", + title: "[{{ repository.name }}] Commented on issue **#{{ issue.number }}**", + url: "{{ comment.html_url }}", + description: "{{ comment.body }}", color: color("green") }] },{ @@ -19,8 +20,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] Issue comment deleted", - url: "{{ repository.html_url }}", + title: "[{{ repository.name }}] Comment on issue **#{{ issue.number }}** deleted", + url: "{{ comment.html_url }}", + description: "{{ comment.body }}", color: color("red") }] },{ @@ -30,8 +32,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] Issue comment edited", - url: "{{ repository.html_url }}", + title: "[{{ repository.name }}] Comment on issue **#{{ issue.number }}** edited", + url: "{{ comment.html_url }}", + description: "{{ comment.body }}", color: color("cyan") }] } diff --git a/templates/label.js b/templates/label.js index 9c56725..0bdca75 100644 --- a/templates/label.js +++ b/templates/label.js @@ -8,8 +8,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `label` (`created`)", + title: "[{{ repository.name }}] Label **{{ label.name }}** created", url: "{{ repository.html_url }}", + description: "{{ label.description }}\n\nColor: #{{ label.color }}", color: color("green") }] },{ @@ -19,8 +20,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `label` (`deleted`)", + title: "[{{ repository.name }}] Label **{{ label.name }}** deleted", url: "{{ repository.html_url }}", + description: "{{ label.description }}\n\nColor: #{{ label.color }}", color: color("red") }] },{ @@ -30,8 +32,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `label` (`edited`)", + title: "[{{ repository.name }}] Label **{{ label.name }}** edited", url: "{{ repository.html_url }}", + description: "{{ label.description }}\n\nColor: #{{ label.color }}", color: color("cyan") }] } diff --git a/templates/meta.js b/templates/meta.js index 97335a5..948e51f 100644 --- a/templates/meta.js +++ b/templates/meta.js @@ -10,6 +10,7 @@ module.exports = [ }, title: "[{{ repository.name }}] This webhook has been deleted", url: "{{ repository.html_url }}", + description: "The following events were enabled:\n```{{ hook.events }}```", color: color("darkRed") }] } diff --git a/templates/personal_access_token_request.js b/templates/personal_access_token_request.js index 778d0b8..a816d85 100644 --- a/templates/personal_access_token_request.js +++ b/templates/personal_access_token_request.js @@ -8,8 +8,11 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `personal_access_token_request` (`approved`)", - url: "{{ repository.html_url }}", + title: "[{{ organization.name }}] Personal access token request was approved", + description: "Requested by {{ personal_access_token_request.owner.login }}", + thumbnail: { + url: "{{ personal_access_token_request.owner.avatar_url }}" + }, color: color("green") }] },{ @@ -19,8 +22,8 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `personal_access_token_request` (`cancelled`)", - url: "{{ repository.html_url }}", + title: "[{{ organization.name }}] Personal access token request was cancelled", + url: "{{ organization.html_url }}", color: color("red") }] },{ @@ -30,8 +33,8 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `personal_access_token_request` (`created`)", - url: "{{ repository.html_url }}", + title: "[{{ organization.name }}] Personal access token requested", + url: "{{ organization.html_url }}", color: color("green") }] },{ @@ -41,9 +44,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `personal_access_token_request` (`denied`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ organization.name }}] Personal access token request was denied", + url: "{{ organization.html_url }}", + color: color("red") }] } ] diff --git a/templates/public.js b/templates/public.js index 7f0186b..8e7b661 100644 --- a/templates/public.js +++ b/templates/public.js @@ -7,9 +7,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `public`", + title: "[{{ repository.full_name }}] Now open source!", url: "{{ repository.html_url }}", - color: color("black") + color: color("darkGreen") }] } ] diff --git a/templates/push.js b/templates/push.js index f7157e9..0df6d7f 100644 --- a/templates/push.js +++ b/templates/push.js @@ -7,8 +7,8 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `push`", - url: "{{ repository.html_url }}", + title: "[{{ repository.name }}:{{ base_ref }}] {{ count(commits) }} new commit(s)", + url: "{{ compare }}", color: color("black") }] } diff --git a/templates/release.js b/templates/release.js index 362bb65..af0a2e6 100644 --- a/templates/release.js +++ b/templates/release.js @@ -8,8 +8,8 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `release` (`created`)", - url: "{{ repository.html_url }}", + title: "[{{ release.name }}] {{ release.draft ? Draft : }} Release created", + url: "{{ release.html_url }}", color: color("green") }] },{ @@ -19,8 +19,7 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `release` (`deleted`)", - url: "{{ repository.html_url }}", + title: "[{{ release.name }}] {{ release.draft ? Draft : }} Release deleted", color: color("red") }] },{ @@ -30,8 +29,8 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `release` (`edited`)", - url: "{{ repository.html_url }}", + title: "[{{ release.name }}] {{ release.draft ? Draft : }} Release edited", + url: "{{ release.html_url }}", color: color("cyan") }] },{ @@ -41,9 +40,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `release` (`prereleased`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ release.name }}] {{ release.draft ? Draft : }} Release prereleased", + url: "{{ release.html_url }}", + color: color("yellow") }] },{ action: "published", @@ -52,9 +51,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `release` (`published`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ release.name }}] {{ release.draft ? Draft : }} Release published", + url: "{{ release.html_url }}", + color: color("green") }] },{ action: "released", @@ -63,9 +62,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `release` (`released`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ release.name }}] {{ release.draft ? Draft : }} Release released", + url: "{{ release.html_url }}", + color: color("green") }] },{ action: "unpublished", @@ -74,9 +73,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `release` (`unpublished`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ release.name }}] {{ release.draft ? Draft : }} Release unpublished", + url: "{{ release.html_url }}", + color: color("red") }] } ] diff --git a/templates/repository_import.js b/templates/repository_import.js index 9861f40..4018f96 100644 --- a/templates/repository_import.js +++ b/templates/repository_import.js @@ -9,6 +9,7 @@ module.exports = [ }, title: "[{{ repository.name }}:{{ repository.default_branch }}] Repository imported", url: "{{ repository.html_url }}", + description: "Status: {{ status }}", color: color("darkGreen") }] } diff --git a/templates/security_advisory.js b/templates/security_advisory.js index c87dbcf..72ac83a 100644 --- a/templates/security_advisory.js +++ b/templates/security_advisory.js @@ -8,9 +8,10 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `security_advisory` (`published`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ repository.name }}] Security advisory published", + url: "https://github.com/advisories/{{ security_advisory.ghsa_id }}", + description: "{{ security_advisory.summary }}", + color: color("red") }] },{ action: "updated", @@ -19,8 +20,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `security_advisory` (`updated`)", - url: "{{ repository.html_url }}", + title: "[{{ repository.name }}] Security advisory updated", + url: "https://github.com/advisories/{{ security_advisory.ghsa_id }}", + description: "{{ security_advisory.summary }}", color: color("cyan") }] },{ @@ -30,9 +32,10 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `security_advisory` (`withdrawn`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ repository.name }}] Security advisory withdrawn", + url: "https://github.com/advisories/{{ security_advisory.ghsa_id }}", + description: "{{ security_advisory.summary }}", + color: color("green") }] } ] diff --git a/templates/security_and_analysis.js b/templates/security_and_analysis.js index b882ab0..9a977a8 100644 --- a/templates/security_and_analysis.js +++ b/templates/security_and_analysis.js @@ -7,9 +7,14 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `security_and_analysis`", + title: "[{{ repository.name }}] Code Security features edited", url: "{{ repository.html_url }}", - color: color("black") + description: + "Code scanning: {{ repository.security_and_analysis.code_scanning_enabled ? Enabled : Disabled }}\n" + + "Secret scanning: {{ repository.security_and_analysis.secret_scanning_enabled ? Enabled : Disabled }}\n" + + "Dependabot alerts: {{ repository.security_and_analysis.dependabot_alerts_enabled ? Enabled : Disabled }}\n" + + "Dependabot security updates: {{ repository.security_and_analysis.dependabot_security_updates_enabled ? Enabled : Disabled }}", + color: color("cyan") }] } ] diff --git a/templates/sponsorship.js b/templates/sponsorship.js index af1075b..308eec8 100644 --- a/templates/sponsorship.js +++ b/templates/sponsorship.js @@ -8,8 +8,8 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `sponsorship` (`cancelled`)", - url: "{{ repository.html_url }}", + title: "[{{ sponsorship.maintainer.login || sponsorship.sponsorable.login }}] Recurring sponsorship cancelled", + url: "{{ sponsorship.maintainer.html_url }}", color: color("red") }] },{ @@ -19,7 +19,7 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `sponsorship` (`created`)", + title: "[{{ sponsorship.maintainer.login || sponsorship.sponsorable.login }}] New sponsor", url: "{{ repository.html_url }}", color: color("green") }] @@ -30,7 +30,7 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `sponsorship` (`edited`)", + title: "[{{ sponsorship.maintainer.login || sponsorship.sponsorable.login }}] Sponsorship edited", url: "{{ repository.html_url }}", color: color("cyan") }] @@ -41,9 +41,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `sponsorship` (`pending_cancellation`)", + title: "[{{ sponsorship.maintainer.login || sponsorship.sponsorable.login }}] Sponsorship will end", url: "{{ repository.html_url }}", - color: color("black") + color: color("gray") }] },{ action: "pending_tier_change", @@ -52,9 +52,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `sponsorship` (`pending_tier_change`)", + title: "[{{ sponsorship.maintainer.login || sponsorship.sponsorable.login }}] Sponsorship tier will change to **{{ sponsorship.tier.name }}**", url: "{{ repository.html_url }}", - color: color("black") + color: color("gray") }] },{ action: "tier_changed", @@ -63,9 +63,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `sponsorship` (`tier_changed`)", + title: "[{{ sponsorship.maintainer.login || sponsorship.sponsorable.login }}] Sponsorship tier changed to **{{ sponsorship.tier.name }}**", url: "{{ repository.html_url }}", - color: color("black") + color: color("cyan") }] } ] diff --git a/templates/star.js b/templates/star.js index 13c1a7c..a54c4df 100644 --- a/templates/star.js +++ b/templates/star.js @@ -6,10 +6,11 @@ module.exports = [ embeds: [{ author: { name: "{{ sender.login }}", - icon_url: "{{ sender.avatar_url }}" + icon_url: "{{ sender.avatar_url }}", + url: "{{ sender.html_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `star` (`created`)", - url: "{{ repository.html_url }}", + title: "[{{ repository.name }}] Star added", + url: "{{ repository.html_url }}/stargazers", color: color("green") }] },{ @@ -17,11 +18,12 @@ module.exports = [ embeds: [{ author: { name: "{{ sender.login }}", - icon_url: "{{ sender.avatar_url }}" + icon_url: "{{ sender.avatar_url }}", + url: "{{ sender.html_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `star` (`deleted`)", - url: "{{ repository.html_url }}", - color: color("red") + title: "[{{ repository.name }}] Star removed", + url: "{{ repository.html_url }}/stargazers", + color: color("gray") }] } ] diff --git a/templates/status.js b/templates/status.js index 1c8f81a..2d9819f 100644 --- a/templates/status.js +++ b/templates/status.js @@ -7,8 +7,8 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `status`", - url: "{{ repository.html_url }}", + title: "[{{ repository.name }}:{{ repository.default_branch }}] Status of commit changed to {{ state }}", + url: "{{ target_url || commit.commit.tree.url }}", color: color("black") }] } diff --git a/templates/workflow_job.js b/templates/workflow_job.js index a38488e..9ef7c4c 100644 --- a/templates/workflow_job.js +++ b/templates/workflow_job.js @@ -30,9 +30,9 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `workflow_job` (`queued`)", + title: "[{{ repository.name }}:{{ repository.default_branch }}] Workflow **{{ workflow.name }}** queued", url: "{{ repository.html_url }}", - color: color("black") + color: color("gray") }] },{ action: "waiting", diff --git a/templates/workflow_run.js b/templates/workflow_run.js index 53a924e..0b2ed95 100644 --- a/templates/workflow_run.js +++ b/templates/workflow_run.js @@ -8,9 +8,13 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `workflow_run` (`completed`)", - url: "{{ repository.html_url }}", - color: color("black") + title: "[{{ workflow_run.head_repository.name }}:{{ workflow_run.head_branch }}] Workflow **{{ workflow.name }}** finished", + url: "{{ workflow_run.html_url }}", + description: "{{ workflow_run.conclusion }}", + image: { + url: "{{ workflow_run.badge_url }}" + }, + color: color("green") }] },{ action: "in_progress", @@ -19,8 +23,12 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `workflow_run` (`in_progress`)", - url: "{{ repository.html_url }}", + title: "[{{ workflow_run.head_repository.name }}:{{ workflow_run.head_branch }}] Workflow **{{ workflow.name }}** started", + url: "{{ workflow_run.html_url }}", + description: "Cancel URL: {{ workflow_run.cancel_url }}", + image: { + url: "{{ workflow_run.badge_url }}" + }, color: color("black") }] },{ @@ -30,8 +38,8 @@ module.exports = [ name: "{{ sender.login }}", icon_url: "{{ sender.avatar_url }}" }, - title: "[{{ repository.name }}:{{ repository.default_branch }}] `workflow_run` (`requested`)", - url: "{{ repository.html_url }}", + title: "[{{ workflow_run.head_repository.name }}:{{ workflow_run.head_branch }}] Workflow **{{ workflow.name }}** requested", + url: "{{ workflow_run.html_url }}", color: color("black") }] }