Compare commits

..

No commits in common. "master" and "v0.0.6" have entirely different histories.

9 changed files with 74941 additions and 221663 deletions

18
.github/eslint-compact.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "eslint-compact",
"pattern": [
{
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}

22
.github/eslint-stylish.json vendored Normal file
View File

@ -0,0 +1,22 @@
{
"problemMatcher": [
{
"owner": "eslint-stylish",
"pattern": [
{
"regexp": "^([^\\s].*)$",
"file": 1
},
{
"regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$",
"line": 1,
"column": 2,
"severity": 3,
"message": 4,
"code": 5,
"loop": true
}
]
}
]
}

17
.github/tsc.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "tsc",
"pattern": [
{
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"location": 2,
"severity": 3,
"code": 4,
"message": 5
}
]
}
]
}

13
.github/workflows/eslint.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Linter
on: [push, pull_request]
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '12'
- run: npm ci
- run: ./node_modules/.bin/eslint -c ./.eslintrc.json -f compact *.js

View File

@ -17,10 +17,9 @@ inputs:
message:
description: 'The message you want to send'
required: true
status:
description: "Job status. Should be bound to job.status. Default to success."
required: false
default: ${{ job.status }}
messagetype:
description: 'Type of Matrix message (e.g. `m.text` or `m.notice`)'
default: 'm.notice'
runs:
using: 'node12'
main: 'dist/index.js'

276775
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,4 @@
const core = require('@actions/core');
const github = require('@actions/github');
const sdk = require('matrix-js-sdk');
const md = require('markdown-it')();
@ -8,24 +7,14 @@ try {
const channel = core.getInput('channel');
const token = core.getInput('token');
const message = core.getInput('message');
const status = core.getInput('status');
const messagetype = core.getInput('messagetype');
// Debug output
core.info(`homeserver: ${homeserver}`);
core.info(`channel: ${channel}`);
core.info(`token: ${token}`);
core.info(`message: ${message}`);
core.info(`status: ${status}`);
const ctx = github.context;
const { owner, repo } = ctx.repo;
const {
ref, workflow, actor, payload, serverUrl, runNumber,
} = ctx;
const repoURL = `${serverUrl}/${owner}/${repo}`;
const runURL = `${repoURL}/actions/runs/${runNumber}`;
core.info(`messagetype: ${messagetype}`);
// Create client object
const client = sdk.createClient({
@ -38,42 +27,17 @@ try {
core.info('Joined channel');
});
const statusOpts = {
success: {
status: '🟢 Success',
color: 0x28A745,
},
failure: {
status: '🔴 Failure',
color: 0xCB2431,
},
cancelled: {
status: 'Cancelled',
color: 0xDBAB09,
},
};
const userMention = status === 'success' ? actor : `<a href="https://matrix.to/#/@${actor}:${homeserver}">${actor}</a>`;
const formattedMessage = `
<h4 data-mx-color="${statusOpts[status].color}">${statusOpts[status].status} ${workflow}</h4>
<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>Ref</strong> ${ref}<br>
<strong>Triggered by</strong> ${userMention}<br>
<strong>Run</strong> <a href="${runURL}">#${runNumber}</a>
${md.render(message)}`;
// render markdown in message
const processedMessage = md.render(message);
// Send message
const content = {
msgtype: (status === 'success') ? 'm.notice' : 'm.text',
msgtype: messagetype,
format: 'org.matrix.custom.html',
body: `${statusOpts[status].status} ${workflow} @${actor}`,
formatted_body: formattedMessage,
body: message,
formatted_body: processedMessage,
};
if (status !== 'success') content['m.mentions'] = { user_ids: [`@${actor}:${homeserver}`] };
client.sendEvent(channel, 'm.room.message', content, '').then(() => {
// message sent successfully
}).catch((err) => {

5000
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,15 +17,15 @@
},
"homepage": "https://github.com/fadenb/Matrix-Chat-Message#readme",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@vercel/ncc": "^0.38.1",
"markdown-it": "^14.1.0",
"matrix-js-sdk": "^32.2.0"
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@vercel/ncc": "^0.24.1",
"markdown-it": "^11.0.1",
"matrix-js-sdk": "^8.4.1"
},
"devDependencies": {
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.29.1"
"eslint": "^7.10.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.1"
}
}