mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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.
This commit is contained in:
committed by
Andrew Seguin
parent
ed72d94e96
commit
98ce6357d3
@@ -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('');
|
||||
}
|
||||
Reference in New Issue
Block a user