Compare commits
No commits in common. "master" and "v0.0.9" have entirely different histories.
@ -21,6 +21,9 @@ inputs:
|
|||||||
description: "Job status. Should be bound to job.status. Default to success."
|
description: "Job status. Should be bound to job.status. Default to success."
|
||||||
required: false
|
required: false
|
||||||
default: ${{ job.status }}
|
default: ${{ job.status }}
|
||||||
|
messagetype:
|
||||||
|
description: 'Type of Matrix message (e.g. `m.text` or `m.notice`)'
|
||||||
|
default: 'm.notice'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
19
dist/index.js
vendored
19
dist/index.js
vendored
@ -231311,6 +231311,7 @@ try {
|
|||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const message = core.getInput('message');
|
const message = core.getInput('message');
|
||||||
const status = core.getInput('status');
|
const status = core.getInput('status');
|
||||||
|
const messagetype = core.getInput('messagetype');
|
||||||
|
|
||||||
// Debug output
|
// Debug output
|
||||||
core.info(`homeserver: ${homeserver}`);
|
core.info(`homeserver: ${homeserver}`);
|
||||||
@ -231318,12 +231319,13 @@ try {
|
|||||||
core.info(`token: ${token}`);
|
core.info(`token: ${token}`);
|
||||||
core.info(`message: ${message}`);
|
core.info(`message: ${message}`);
|
||||||
core.info(`status: ${status}`);
|
core.info(`status: ${status}`);
|
||||||
|
core.info(`messagetype: ${messagetype}`);
|
||||||
|
|
||||||
const ctx = github.context;
|
const ctx = github.context;
|
||||||
|
|
||||||
const { owner, repo } = ctx.repo;
|
const { owner, repo } = ctx.repo;
|
||||||
const {
|
const {
|
||||||
ref, workflow, actor, payload, serverUrl, runNumber,
|
workflow, actor, payload, serverUrl, runNumber,
|
||||||
} = ctx;
|
} = ctx;
|
||||||
|
|
||||||
const repoURL = `${serverUrl}/${owner}/${repo}`;
|
const repoURL = `${serverUrl}/${owner}/${repo}`;
|
||||||
@ -231342,11 +231344,11 @@ try {
|
|||||||
|
|
||||||
const statusOpts = {
|
const statusOpts = {
|
||||||
success: {
|
success: {
|
||||||
status: '🟢 Success',
|
status: 'Success',
|
||||||
color: 0x28A745,
|
color: 0x28A745,
|
||||||
},
|
},
|
||||||
failure: {
|
failure: {
|
||||||
status: '🔴 Failure',
|
status: 'Failure',
|
||||||
color: 0xCB2431,
|
color: 0xCB2431,
|
||||||
},
|
},
|
||||||
cancelled: {
|
cancelled: {
|
||||||
@ -231358,23 +231360,22 @@ try {
|
|||||||
const userMention = status === 'success' ? actor : `<a href="https://matrix.to/#/@${actor}:${homeserver}">${actor}</a>`;
|
const userMention = status === 'success' ? actor : `<a href="https://matrix.to/#/@${actor}:${homeserver}">${actor}</a>`;
|
||||||
|
|
||||||
const formattedMessage = `
|
const formattedMessage = `
|
||||||
<h4 data-mx-color="${statusOpts[status].color}">${statusOpts[status].status} ${workflow}</h4>
|
<h4 style="color: ${statusOpts[status].color}">${statusOpts[status].status} ${workflow.name}</h4>
|
||||||
<p><strong>Repository</strong> <a href="${repoURL}">${owner}/${repo}</a><br>
|
<p><strong>Repository</strong> <a href="${repoURL}">${owner}/${repo}</a><br>
|
||||||
<strong>Commit</strong> <a href="${payload.head_commit.url}">${payload.head_commit.id.substring(0, 7)}</a> ${payload.head_commit.message}<br>
|
<strong>Commit</strong> <a href="${payload.head_commit.url}">${payload.head_commit.id.substring(0, 7)}</a> ${payload.head_commit.message}<br>
|
||||||
<strong>Ref</strong> ${ref}<br>
|
|
||||||
<strong>Triggered by</strong> ${userMention}<br>
|
<strong>Triggered by</strong> ${userMention}<br>
|
||||||
<strong>Run</strong> <a href="${runURL}">#${runNumber}</a>
|
<strong>Run</strong> <a href="${runURL}">#${runNumber}</a><br>
|
||||||
${md.render(message)}`;
|
${md.render(message)}`;
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
const content = {
|
const content = {
|
||||||
msgtype: (status === 'success') ? 'm.notice' : 'm.text',
|
msgtype: messagetype,
|
||||||
format: 'org.matrix.custom.html',
|
format: 'org.matrix.custom.html',
|
||||||
body: `${statusOpts[status].status} ${workflow} @${actor}`,
|
body: message,
|
||||||
formatted_body: formattedMessage,
|
formatted_body: formattedMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (status !== 'success') content['m.mentions'] = { user_ids: [`@${actor}:${homeserver}`] };
|
if (status === 'success') content['m.mentions'] = { user_ids: [`@${actor}:${homeserver}`] };
|
||||||
|
|
||||||
client.sendEvent(channel, 'm.room.message', content, '').then(() => {
|
client.sendEvent(channel, 'm.room.message', content, '').then(() => {
|
||||||
// message sent successfully
|
// message sent successfully
|
||||||
|
|||||||
16
index.js
16
index.js
@ -9,6 +9,7 @@ try {
|
|||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const message = core.getInput('message');
|
const message = core.getInput('message');
|
||||||
const status = core.getInput('status');
|
const status = core.getInput('status');
|
||||||
|
const messagetype = core.getInput('messagetype');
|
||||||
|
|
||||||
// Debug output
|
// Debug output
|
||||||
core.info(`homeserver: ${homeserver}`);
|
core.info(`homeserver: ${homeserver}`);
|
||||||
@ -16,6 +17,7 @@ try {
|
|||||||
core.info(`token: ${token}`);
|
core.info(`token: ${token}`);
|
||||||
core.info(`message: ${message}`);
|
core.info(`message: ${message}`);
|
||||||
core.info(`status: ${status}`);
|
core.info(`status: ${status}`);
|
||||||
|
core.info(`messagetype: ${messagetype}`);
|
||||||
|
|
||||||
const ctx = github.context;
|
const ctx = github.context;
|
||||||
|
|
||||||
@ -40,11 +42,11 @@ try {
|
|||||||
|
|
||||||
const statusOpts = {
|
const statusOpts = {
|
||||||
success: {
|
success: {
|
||||||
status: '🟢 Success',
|
status: 'Success',
|
||||||
color: 0x28A745,
|
color: 0x28A745,
|
||||||
},
|
},
|
||||||
failure: {
|
failure: {
|
||||||
status: '🔴 Failure',
|
status: 'Failure',
|
||||||
color: 0xCB2431,
|
color: 0xCB2431,
|
||||||
},
|
},
|
||||||
cancelled: {
|
cancelled: {
|
||||||
@ -56,19 +58,19 @@ try {
|
|||||||
const userMention = status === 'success' ? actor : `<a href="https://matrix.to/#/@${actor}:${homeserver}">${actor}</a>`;
|
const userMention = status === 'success' ? actor : `<a href="https://matrix.to/#/@${actor}:${homeserver}">${actor}</a>`;
|
||||||
|
|
||||||
const formattedMessage = `
|
const formattedMessage = `
|
||||||
<h4 data-mx-color="${statusOpts[status].color}">${statusOpts[status].status} ${workflow}</h4>
|
<h4 style="color: ${statusOpts[status].color}">${statusOpts[status].status} ${workflow}</h4>
|
||||||
<p><strong>Repository</strong> <a href="${repoURL}">${owner}/${repo}</a><br>
|
<p><strong>Repository</strong> <a href="${repoURL}">${owner}/${repo}</a><br>
|
||||||
<strong>Commit</strong> <a href="${payload.head_commit.url}">${payload.head_commit.id.substring(0, 7)}</a> ${payload.head_commit.message}<br>
|
<strong>Commit</strong> <a href="${payload.head_commit.url}">${payload.head_commit.id.substring(0, 7)}</a> ${payload.head_commit.message}<br>
|
||||||
<strong>Ref</strong> ${ref}<br>
|
<strong>Ref</strong> ref<br>
|
||||||
<strong>Triggered by</strong> ${userMention}<br>
|
<strong>Triggered by</strong> ${userMention}<br>
|
||||||
<strong>Run</strong> <a href="${runURL}">#${runNumber}</a>
|
<strong>Run</strong> <a href="${runURL}">#${runNumber}</a><br>
|
||||||
${md.render(message)}`;
|
${md.render(message)}`;
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
const content = {
|
const content = {
|
||||||
msgtype: (status === 'success') ? 'm.notice' : 'm.text',
|
msgtype: messagetype,
|
||||||
format: 'org.matrix.custom.html',
|
format: 'org.matrix.custom.html',
|
||||||
body: `${statusOpts[status].status} ${workflow} @${actor}`,
|
body: message,
|
||||||
formatted_body: formattedMessage,
|
formatted_body: formattedMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user