Skip to content

Commit

Permalink
add repository_dispatch and fix PR case
Browse files Browse the repository at this point in the history
  • Loading branch information
megamegax committed Feb 8, 2024
1 parent 44de161 commit 3629ef5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
22 changes: 20 additions & 2 deletions MessageFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ export default class Message {
htmlUrl = context.payload.repository.html_url;
}
const runUrl = `${htmlUrl}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const commitId = context.sha.substring(0, 7);
switch (eventName) {
case 'pull_request':
return {
text: `(<${context.payload.repository.compare_url}|${commitId}>) for PR <${context.payload.pull_request.html_url}| #${context.payload.pull_request.number} ${context.payload.pull_request.title}>`,
text: `<${context.payload.pull_request.html_url}|Pull Request(#${context.payload.pull_request.number}) - ${context.payload.pull_request.title}>`,
fields: [
{
title: 'Repository',
Expand Down Expand Up @@ -160,6 +159,25 @@ export default class Message {
{ title: 'Workflow', value: `<${runUrl}|${process.env.GITHUB_WORKFLOW}>`, short: true }
]
};
case 'repository_dispatch':
return {
title: `<${runUrl}| triggered automatically>`,
text: '',
fields: [
{
title: 'Repository',
value: `<${context.payload.repository.html_url}|${context.payload.repository.full_name}>`,
short: true
},
{
title: 'Branch',
value: `<${process.env.GITHUB_HEAD_REF ||
(process.env.GITHUB_REF && process.env.GITHUB_REF.split('/')[2])}>`,
short: true
},
{ title: 'Workflow', value: `<${runUrl}|${process.env.GITHUB_WORKFLOW}>`, short: true }
]
};
case 'schedule':
console.log(context);
console.log(context.payload);
Expand Down
22 changes: 20 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37591,11 +37591,10 @@ class Message {
htmlUrl = context.payload.repository.html_url;
}
const runUrl = `${htmlUrl}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const commitId = context.sha.substring(0, 7);
switch (eventName) {
case 'pull_request':
return {
text: `(<${context.payload.repository.compare_url}|${commitId}>) for PR <${context.payload.pull_request.html_url}| #${context.payload.pull_request.number} ${context.payload.pull_request.title}>`,
text: `<${context.payload.pull_request.html_url}|Pull Request(#${context.payload.pull_request.number}) - ${context.payload.pull_request.title}>`,
fields: [
{
title: 'Repository',
Expand Down Expand Up @@ -37677,6 +37676,25 @@ class Message {
{ title: 'Workflow', value: `<${runUrl}|${process.env.GITHUB_WORKFLOW}>`, short: true }
]
};
case 'repository_dispatch':
return {
title: `<${runUrl}| triggered automatically>`,
text: '',
fields: [
{
title: 'Repository',
value: `<${context.payload.repository.html_url}|${context.payload.repository.full_name}>`,
short: true
},
{
title: 'Branch',
value: `<${process.env.GITHUB_HEAD_REF ||
(process.env.GITHUB_REF && process.env.GITHUB_REF.split('/')[2])}>`,
short: true
},
{ title: 'Workflow', value: `<${runUrl}|${process.env.GITHUB_WORKFLOW}>`, short: true }
]
};
case 'schedule':
console.log(context);
console.log(context.payload);
Expand Down

0 comments on commit 3629ef5

Please sign in to comment.