Compare commits
7 Commits
dependabot
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b5883db88 | |||
| d9e8862eb8 | |||
| d454e89334 | |||
| 4c101e89ae | |||
| e07a81e055 | |||
| bd08ecaf97 | |||
| 18ea2450af |
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@ -1,11 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "npm" # See documentation for possible values
|
|
||||||
directory: "/" # Location of package manifests
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
18
.github/eslint-compact.json
vendored
18
.github/eslint-compact.json
vendored
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"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
22
.github/eslint-stylish.json
vendored
@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"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
17
.github/tsc.json
vendored
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"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
13
.github/workflows/eslint.yml
vendored
@ -1,13 +0,0 @@
|
|||||||
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
|
|
||||||
@ -17,9 +17,10 @@ inputs:
|
|||||||
message:
|
message:
|
||||||
description: 'The message you want to send'
|
description: 'The message you want to send'
|
||||||
required: true
|
required: true
|
||||||
messagetype:
|
status:
|
||||||
description: 'Type of Matrix message (e.g. `m.text` or `m.notice`)'
|
description: "Job status. Should be bound to job.status. Default to success."
|
||||||
default: 'm.notice'
|
required: false
|
||||||
|
default: ${{ job.status }}
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
277329
dist/index.js
vendored
277329
dist/index.js
vendored
File diff suppressed because one or more lines are too long
50
index.js
50
index.js
@ -1,4 +1,5 @@
|
|||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
|
const github = require('@actions/github');
|
||||||
const sdk = require('matrix-js-sdk');
|
const sdk = require('matrix-js-sdk');
|
||||||
const md = require('markdown-it')();
|
const md = require('markdown-it')();
|
||||||
|
|
||||||
@ -7,14 +8,24 @@ try {
|
|||||||
const channel = core.getInput('channel');
|
const channel = core.getInput('channel');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const message = core.getInput('message');
|
const message = core.getInput('message');
|
||||||
const messagetype = core.getInput('messagetype');
|
const status = core.getInput('status');
|
||||||
|
|
||||||
// Debug output
|
// Debug output
|
||||||
core.info(`homeserver: ${homeserver}`);
|
core.info(`homeserver: ${homeserver}`);
|
||||||
core.info(`channel: ${channel}`);
|
core.info(`channel: ${channel}`);
|
||||||
core.info(`token: ${token}`);
|
core.info(`token: ${token}`);
|
||||||
core.info(`message: ${message}`);
|
core.info(`message: ${message}`);
|
||||||
core.info(`messagetype: ${messagetype}`);
|
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}`;
|
||||||
|
|
||||||
// Create client object
|
// Create client object
|
||||||
const client = sdk.createClient({
|
const client = sdk.createClient({
|
||||||
@ -27,17 +38,42 @@ try {
|
|||||||
core.info('Joined channel');
|
core.info('Joined channel');
|
||||||
});
|
});
|
||||||
|
|
||||||
// render markdown in message
|
const statusOpts = {
|
||||||
const processedMessage = md.render(message);
|
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)}`;
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
const content = {
|
const content = {
|
||||||
msgtype: messagetype,
|
msgtype: (status === 'success') ? 'm.notice' : 'm.text',
|
||||||
format: 'org.matrix.custom.html',
|
format: 'org.matrix.custom.html',
|
||||||
body: message,
|
body: `${statusOpts[status].status} ${workflow} @${actor}`,
|
||||||
formatted_body: processedMessage,
|
formatted_body: formattedMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
|||||||
20
package-lock.json
generated
20
package-lock.json
generated
@ -57,9 +57,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/runtime": {
|
"@babel/runtime": {
|
||||||
"version": "7.24.7",
|
"version": "7.24.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.5.tgz",
|
||||||
"integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==",
|
"integrity": "sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"regenerator-runtime": "^0.14.0"
|
"regenerator-runtime": "^0.14.0"
|
||||||
}
|
}
|
||||||
@ -131,9 +131,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@matrix-org/matrix-sdk-crypto-wasm": {
|
"@matrix-org/matrix-sdk-crypto-wasm": {
|
||||||
"version": "5.0.0",
|
"version": "4.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-4.9.0.tgz",
|
||||||
"integrity": "sha512-37ASjCKSTU5ycGfkP+LUXG4Ok6OAf6vE+1qU6uwWhe6FwadCS3vVWzJYd/3d9BQFwsx4GhFTIAXrW4iLG85rmQ=="
|
"integrity": "sha512-/bgA4QfE7qkK6GFr9hnhjAvRSebGrmEJxukU0ukbudZcYvbzymoBBM8j3HeULXZT8kbw8WH6z63txYTMCBSDOA=="
|
||||||
},
|
},
|
||||||
"@nodelib/fs.scandir": {
|
"@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
@ -2871,12 +2871,12 @@
|
|||||||
"integrity": "sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA=="
|
"integrity": "sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA=="
|
||||||
},
|
},
|
||||||
"matrix-js-sdk": {
|
"matrix-js-sdk": {
|
||||||
"version": "33.1.0",
|
"version": "32.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-33.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-32.2.0.tgz",
|
||||||
"integrity": "sha512-Spf+g156eK+SqPd7EuulTVwpyHkVXR0Ikme04fMCKer+SbzuLPPnqV3gL5cSyTMmHbdNejEJaEvzNIMQoD7Xxw==",
|
"integrity": "sha512-LnfJNq5nMF/R+Wigv7dP+Q6I/D5zKHOIdGg9mYyQmhpLc+skWLCtjqa4cLH+hq5CUyppQXMuPH/FFQaGQQ3ImA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@matrix-org/matrix-sdk-crypto-wasm": "^5.0.0",
|
"@matrix-org/matrix-sdk-crypto-wasm": "^4.9.0",
|
||||||
"another-json": "^0.2.0",
|
"another-json": "^0.2.0",
|
||||||
"bs58": "^5.0.0",
|
"bs58": "^5.0.0",
|
||||||
"content-type": "^1.0.4",
|
"content-type": "^1.0.4",
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
"@actions/github": "^6.0.0",
|
"@actions/github": "^6.0.0",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"markdown-it": "^14.1.0",
|
"markdown-it": "^14.1.0",
|
||||||
"matrix-js-sdk": "^33.1.0"
|
"matrix-js-sdk": "^32.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user