diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-18 05:42:07 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-18 05:42:07 +0900 |
| commit | 2496cece91c6d064c6f6103c0918a244d15588ed (patch) | |
| tree | cd532152c09559014d8ac2b33e6652b8e760b791 /src/api/service/github.ts | |
| parent | Merge pull request #296 from ha-dai/master (diff) | |
| download | sharkey-2496cece91c6d064c6f6103c0918a244d15588ed.tar.gz sharkey-2496cece91c6d064c6f6103c0918a244d15588ed.tar.bz2 sharkey-2496cece91c6d064c6f6103c0918a244d15588ed.zip | |
Better notification
Diffstat (limited to 'src/api/service/github.ts')
| -rw-r--r-- | src/api/service/github.ts | 24 |
1 files changed, 23 insertions, 1 deletions
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; } }); |