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'
|
||||||
|
|||||||
275467
dist/index.js
vendored
275467
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) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user