Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7032888
fix: targetをesnextにする
samunohito Apr 14, 2025
90344c7
Create dependabot.yml
samunohito Apr 14, 2025
0bbea38
Merge pull request #1 from samunohito/fix/add-dependabot
samunohito Apr 14, 2025
547973b
Bump @types/request from 2.48.5 to 2.48.12
dependabot[bot] Apr 14, 2025
e8496b2
Bump ts-node from 9.0.0 to 10.9.2
dependabot[bot] Apr 14, 2025
b174763
Bump koa-bodyparser from 4.3.0 to 4.4.1
dependabot[bot] Apr 14, 2025
5e65b74
Merge pull request #2 from samunohito/dependabot/npm_and_yarn/types/r…
samunohito Apr 14, 2025
ae5147d
Merge pull request #3 from samunohito/dependabot/npm_and_yarn/ts-node…
samunohito Apr 14, 2025
0b30cd2
Merge pull request #5 from samunohito/dependabot/npm_and_yarn/koa-bod…
samunohito Apr 14, 2025
c8354a7
Bump typescript from 4.1.2 to 5.8.3
dependabot[bot] Apr 14, 2025
3e6c56d
Bump koa and @types/koa
dependabot[bot] Apr 14, 2025
cc806d1
Merge pull request #4 from samunohito/dependabot/npm_and_yarn/typescr…
samunohito Apr 14, 2025
9a7ff1f
Merge pull request #6 from samunohito/dependabot/npm_and_yarn/multi-f…
samunohito Apr 14, 2025
ec3fea0
Merge branch 'fix/tsconfig-target-to-esnext'
samunohito Apr 14, 2025
9fae384
Bump koa-router from 10.0.0 to 13.0.1
dependabot[bot] Apr 14, 2025
cb517d8
Bump @types/node from 14.14.9 to 22.14.1
dependabot[bot] Apr 14, 2025
3b2fd7b
Merge pull request #7 from samunohito/dependabot/npm_and_yarn/koa-rou…
samunohito Apr 14, 2025
2076176
Merge pull request #8 from samunohito/dependabot/npm_and_yarn/types/n…
samunohito Apr 14, 2025
089cb96
Bump @types/koa-router from 7.4.1 to 7.4.8
dependabot[bot] Apr 14, 2025
ca078d9
Merge pull request #9 from samunohito/dependabot/npm_and_yarn/types/k…
samunohito Apr 15, 2025
3b74ec1
fix: remove crypto
samunohito Apr 14, 2025
25b19e4
Merge branch 'fix/remove-crypto' into develop
samunohito Apr 16, 2025
69c8d5b
fix: requestやめる
samunohito Apr 16, 2025
0bcfd3d
Merge branch 'master' into develop
samunohito Apr 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
"build": "tsc"
},
"dependencies": {
"@types/koa": "2.11.6",
"@types/koa": "2.15.0",
"@types/koa-bodyparser": "5.0.2",
"@types/koa-router": "7.4.1",
"@types/node": "14.14.9",
"@types/request": "2.48.5",
"crypto": "1.0.1",
"koa": "2.13.0",
"koa-bodyparser": "4.3.0",
"koa-router": "10.0.0",
"request": "2.88.2",
"ts-node": "9.0.0",
"typescript": "4.1.2"
"@types/koa-router": "7.4.8",
"@types/node": "22.14.1",
"@types/request": "2.48.12",
"koa": "2.16.1",
"koa-bodyparser": "4.4.1",
"koa-router": "13.0.1",
"ts-node": "10.9.2",
"typescript": "5.8.3"
},
"devDependencies": {
"@octokit/webhooks": "^13.2.7"
"@octokit/webhooks": "13.8.0"
}
}
49 changes: 27 additions & 22 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { EventEmitter } from 'events';
import * as Koa from 'koa';
import * as Router from 'koa-router';
import * as bodyParser from 'koa-bodyparser';
import * as request from 'request';
import crypto = require('crypto');
import * as crypto from 'node:crypto';
import type { EventPayloadMap } from '@octokit/webhooks/dist-types/generated/webhook-identifiers';

const config = require('../config.json');
Expand All @@ -19,15 +18,23 @@ class WebhookEventEmitter extends EventEmitter {
const handler = new WebhookEventEmitter();

const post = async (text: string, home = true) => {
request.post(config.instance + '/api/notes/create', {
json: {
const instance = config.instance.endsWith('/')
? config.instance.substring(0, config.instance.length - 1)
: config.instance;

await fetch(`${instance}/api/notes/create`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
i: config.i,
text,
visibility: home ? 'home' : 'public',
noExtractMentions: true,
noExtractHashtags: true
}
});
noExtractHashtags: true,
}),
})
};

const app = new Koa();
Expand All @@ -40,7 +47,7 @@ const router = new Router();
router.post('/github', ctx => {
const body = JSON.stringify(ctx.request.body);
const hash = crypto.createHmac('sha1', secret).update(body).digest('hex');
const sig1 = Buffer.from(ctx.headers['x-hub-signature']);
const sig1 = Buffer.from(ctx.headers['x-hub-signature'] as string);
const sig2 = Buffer.from(`sha1=${hash}`);

// シグネチャ比較
Expand All @@ -59,7 +66,7 @@ const server = http.createServer(app.callback());

server.listen(config.port);

handler.on('status', event => {
handler.on('status', async event => {
const state = event.state;
switch (state) {
case 'error':
Expand All @@ -68,26 +75,24 @@ handler.on('status', event => {
const parent = commit.parents[0];

// Fetch parent status
request({
url: `${parent.url}/statuses`,
proxy: config.proxy,
await fetch(`${parent.url}/statuses`, {
method: "GET",
headers: {
'User-Agent': 'misskey'
}
}, (err, res, body) => {
if (err) {
console.error(err);
return;
}
const parentStatuses = JSON.parse(body);
},
}).then(async res => {
const parentStatuses = await res.json()
const parentState = parentStatuses[0]?.state;
const stillFailed = parentState === 'failure' || parentState === 'error';
if (stillFailed) {
post(`⚠️ **BUILD STILL FAILED** ⚠️: ?[${commit.commit.message}](${commit.html_url})`);
await post(`⚠️ **BUILD STILL FAILED** ⚠️: ?[${commit.commit.message}](${commit.html_url})`);
} else {
post(`🚨 **BUILD FAILED** 🚨: → ?[${commit.commit.message}](${commit.html_url}) ←`);
await post(`🚨 **BUILD FAILED** 🚨: → ?[${commit.commit.message}](${commit.html_url}) ←`);
}
});
}).catch(err => {
console.error(err);
})

break;
}
});
Expand Down