From 98ce6357d30de4ddbd63962deb48070928381bdc Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 5 Jun 2017 23:50:14 +0200 Subject: [PATCH] build: remove github status api (#4957) Removes the Github Status API from Gulp since it's not used anymore and won't be used anymore. The reason is that all API requests to Gtihub will happen from Firebase functions Sending requests to the Github API from Firebase functions ensures that nobody can leak Github / Access tokens and that we can send API requests for Pull Requests too. --- tools/gulp/util/github.ts | 46 --------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 tools/gulp/util/github.ts diff --git a/tools/gulp/util/github.ts b/tools/gulp/util/github.ts deleted file mode 100644 index 6882db79fc0..00000000000 --- a/tools/gulp/util/github.ts +++ /dev/null @@ -1,46 +0,0 @@ -import {MATERIAL_VERSION} from '../build-config'; - -const request = require('request'); - -/** Data that must be specified to set a Github PR status. */ -export type GithubStatusData = { - result: boolean; - name: string; - description: string; - url: string; -}; - -/** Function that sets a Github commit status */ -export function setGithubStatus(commitSHA: number, statusData: GithubStatusData) { - let state = statusData.result ? 'success' : 'failure'; - let token = decode(process.env['MATERIAL2_GITHUB_STATUS_TOKEN']); - - let data = JSON.stringify({ - state: state, - target_url: statusData.url, - context: statusData.name, - description: statusData.description - }); - - let headers = { - 'Authorization': `token ${token}`, - 'User-Agent': `${statusData.name}/${MATERIAL_VERSION}`, - 'Content-Type': 'application/json', - 'Content-Length': Buffer.byteLength(data) - }; - - return new Promise((resolve) => { - request({ - url: `https://api.github.com/repos/angular/material2/statuses/${commitSHA}`, - method: 'POST', - form: data, - headers: headers - }, function (error: any, response: any) { - resolve(response.statusCode); - }); - }); -} - -function decode(value: string): string { - return value.split('').reverse().join(''); -}