mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore(dashboard): http function to list pull requests with conflicts (#6675)
Introduces a new http trigger in the Dashboard functions that returns all Pull Requests with merge conflicts. This allows us to show a list of PRs with merge conflicts in the dashboard. To ensure that the API calls are as fast as possible, the pull requests with conflicts are queried using Github's new GraphQL API.
This commit is contained in:
committed by
Jeremy Elbourn
parent
248dee8265
commit
c021e94fce
@@ -1,10 +1,4 @@
|
||||
import {config} from 'firebase-functions';
|
||||
|
||||
const request = require('request');
|
||||
const {version, name} = require('../package.json');
|
||||
|
||||
/** API token for the Github repository. Required to set the github status on commits and PRs. */
|
||||
const repoToken = config().secret.github;
|
||||
import {githubApiV3} from './github-api';
|
||||
|
||||
/** Data that must be specified to set a Github PR status. */
|
||||
export type GithubStatusData = {
|
||||
@@ -18,25 +12,13 @@ export type GithubStatusData = {
|
||||
export function setGithubStatus(commitSHA: string, data: GithubStatusData) {
|
||||
const state = data.result ? 'success' : 'failure';
|
||||
|
||||
const requestData = {
|
||||
return githubApiV3.repos.createStatus({
|
||||
owner: 'angular',
|
||||
repo: 'material2',
|
||||
sha: commitSHA,
|
||||
state: state,
|
||||
target_url: data.url,
|
||||
description: data.description,
|
||||
context: data.name,
|
||||
description: data.description
|
||||
};
|
||||
|
||||
const headers = {
|
||||
'Authorization': `token ${repoToken}`,
|
||||
'User-Agent': `${name}/${version}`
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: `https://api.github.com/repos/angular/material2/statuses/${commitSHA}`,
|
||||
method: 'POST',
|
||||
body: requestData,
|
||||
headers: headers,
|
||||
json: true
|
||||
}, (error: any, response: any) => error ? reject(error) : resolve(response.statusCode));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user