Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13,610 changes: 8,071 additions & 5,539 deletions .github/actions/javascript/awaitStagingDeploys/index.js

Large diffs are not rendered by default.

13,612 changes: 8,072 additions & 5,540 deletions .github/actions/javascript/checkDeployBlockers/index.js

Large diffs are not rendered by default.

23,382 changes: 12,957 additions & 10,425 deletions .github/actions/javascript/createOrUpdateStagingDeploy/index.js

Large diffs are not rendered by default.

9,894 changes: 6,134 additions & 3,760 deletions .github/actions/javascript/getDeployPullRequestList/index.js

Large diffs are not rendered by default.

13,612 changes: 8,072 additions & 5,540 deletions .github/actions/javascript/getPullRequestDetails/index.js

Large diffs are not rendered by default.

13,612 changes: 8,072 additions & 5,540 deletions .github/actions/javascript/getReleaseBody/index.js

Large diffs are not rendered by default.

13,610 changes: 8,071 additions & 5,539 deletions .github/actions/javascript/isPullRequestMergeable/index.js

Large diffs are not rendered by default.

13,612 changes: 8,072 additions & 5,540 deletions .github/actions/javascript/isStagingDeployLocked/index.js

Large diffs are not rendered by default.

13,614 changes: 8,073 additions & 5,541 deletions .github/actions/javascript/markPullRequestsAsDeployed/index.js

Large diffs are not rendered by default.

13,612 changes: 8,072 additions & 5,540 deletions .github/actions/javascript/reopenIssueWithComment/index.js

Large diffs are not rendered by default.

13,610 changes: 8,071 additions & 5,539 deletions .github/actions/javascript/triggerWorkflowAndWait/index.js

Large diffs are not rendered by default.

13,614 changes: 8,073 additions & 5,541 deletions .github/actions/javascript/verifySignedCommits/index.js

Large diffs are not rendered by default.

51 changes: 39 additions & 12 deletions .github/libs/GithubUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const lodashGet = require('lodash/get');
const core = require('@actions/core');
const {GitHub, getOctokitOptions} = require('@actions/github/lib/utils');
const {throttling} = require('@octokit/plugin-throttling');
const {paginateRest} = require('@octokit/plugin-paginate-rest');

const GITHUB_OWNER = 'Expensify';
const APP_REPO = 'App';
Expand All @@ -27,19 +28,16 @@ const POLL_RATE = 10000;

class GithubUtils {
/**
* Either give an existing instance of Octokit or create a new one
* Initialize internal octokit
*
* @readonly
* @static
* @memberof GithubUtils
* @private
*/
static get octokit() {
if (this.octokitInternal) {
return this.octokitInternal;
}
const OctokitThrottled = GitHub.plugin(throttling);
static initOctokit() {
const Octokit = GitHub.plugin(throttling, paginateRest);
const token = core.getInput('GITHUB_TOKEN', {required: true});
this.octokitInternal = new OctokitThrottled(getOctokitOptions(token, {

// Save a copy of octokit used in this class
this.internalOctokit = new Octokit(getOctokitOptions(token, {
throttle: {
onRateLimit: (retryAfter, options) => {
console.warn(
Expand All @@ -60,7 +58,36 @@ class GithubUtils {
},
},
}));
return this.octokitInternal;
}

/**
* Either give an existing instance of Octokit rest or create a new one
*
* @readonly
* @static
* @memberof GithubUtils
*/
static get octokit() {
if (this.internalOctokit) {
return this.internalOctokit.rest;
}
this.initOctokit();
return this.internalOctokit.rest;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
* @readonly
* @static
* @memberof GithubUtils
*/
static get paginate() {
if (this.internalOctokit) {
return this.internalOctokit.paginate;
}
this.initOctokit();
return this.internalOctokit.paginate;
}

/**
Expand Down Expand Up @@ -325,7 +352,7 @@ class GithubUtils {
*/
static fetchAllPullRequests(pullRequestNumbers) {
const oldestPR = _.first(_.sortBy(pullRequestNumbers));
return this.octokit.paginate(this.octokit.pulls.list, {
return this.paginate(this.octokit.pulls.list, {
owner: GITHUB_OWNER,
repo: APP_REPO,
state: 'all',
Expand Down
Loading