From 2496cece91c6d064c6f6103c0918a244d15588ed Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Mar 2017 05:42:07 +0900 Subject: [PATCH] Better notification --- src/api/service/github.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/api/service/github.ts b/src/api/service/github.ts index deb8c192d2..b2e7cbfd69 100644 --- a/src/api/service/github.ts +++ b/src/api/service/github.ts @@ -1,5 +1,6 @@ import * as EventEmitter from 'events'; import * as express from 'express'; +import * as request from 'request'; const crypto = require('crypto'); import User from '../models/user'; import config from '../../conf'; @@ -34,7 +35,28 @@ module.exports = async (app: express.Application) => { switch (state) { case 'failure': const commit = event.commit; - post(`⚠️🚨BUILD FAILED🚨⚠️: ?[${commit.commit.message}](${commit.html_url})`); + const parent = commit.parents[0]; + + // Fetch parent status + request({ + url: parent.url + '/statuses', + headers: { + 'User-Agent': 'misskey' + } + }, (err, res, body) => { + if (err) { + console.error(err); + return; + } + const parentStatuses = JSON.parse(body); + const parentState = parentStatuses[0].state; + const stillFailed = parentState == 'failure'; + if (stillFailed) { + post(`**⚠️BUILD STILL FAILED⚠️**: ?[${commit.commit.message}](${commit.html_url})`); + } else { + post(`**🚨BUILD FAILED🚨**: →→→?[${commit.commit.message}](${commit.html_url})←←←`); + } + }); break; } });