Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 404 errors when we have a bad PR referenced in the PR list #41809

Merged
merged 7 commits into from
Jun 21, 2024
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
28 changes: 19 additions & 9 deletions .github/actions/javascript/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11598,15 +11598,25 @@ async function run() {
* 1. For regular staging deploys, the person who merged the PR.
* 2. For CPs, the person who committed the cherry-picked commit (not necessarily the author of the commit).
*/
const { data: pr } = await GithubUtils_1.default.octokit.pulls.get({
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
pull_number: prNumber,
});
const deployer = isCP ? commit.committer.name : pr.merged_by?.login;
const title = pr.title;
const deployMessage = deployer ? getDeployMessage(deployer, isCP ? 'Cherry-picked' : 'Deployed', title) : '';
await commentPR(prNumber, deployMessage);
try {
const { data: pr } = await GithubUtils_1.default.octokit.pulls.get({
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
pull_number: prNumber,
});
const deployer = isCP ? commit.committer.name : pr.merged_by?.login;
const title = pr.title;
const deployMessage = deployer ? getDeployMessage(deployer, isCP ? 'Cherry-picked' : 'Deployed', title) : '';
await commentPR(prNumber, deployMessage);
}
catch (error) {
if (error.status === 404) {
console.log(`Unable to comment on PR #${prNumber}. GitHub responded with 404.`);
}
else {
throw error;
}
}
}
}
if (require.main === require.cache[eval('__filename')]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention, import/no-import-module-exports */
import * as core from '@actions/core';
import {context} from '@actions/github';
import type {RequestError} from '@octokit/types';
import * as ActionUtils from '@github/libs/ActionUtils';
import CONST from '@github/libs/CONST';
import GithubUtils from '@github/libs/GithubUtils';
Expand Down Expand Up @@ -113,16 +114,24 @@ async function run() {
* 1. For regular staging deploys, the person who merged the PR.
* 2. For CPs, the person who committed the cherry-picked commit (not necessarily the author of the commit).
*/
const {data: pr} = await GithubUtils.octokit.pulls.get({
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
pull_number: prNumber,
});
const deployer = isCP ? commit.committer.name : pr.merged_by?.login;

const title = pr.title;
const deployMessage = deployer ? getDeployMessage(deployer, isCP ? 'Cherry-picked' : 'Deployed', title) : '';
await commentPR(prNumber, deployMessage);
try {
const {data: pr} = await GithubUtils.octokit.pulls.get({
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
pull_number: prNumber,
});
const deployer = isCP ? commit.committer.name : pr.merged_by?.login;

const title = pr.title;
const deployMessage = deployer ? getDeployMessage(deployer, isCP ? 'Cherry-picked' : 'Deployed', title) : '';
await commentPR(prNumber, deployMessage);
} catch (error) {
if ((error as RequestError).status === 404) {
console.log(`Unable to comment on PR #${prNumber}. GitHub responded with 404.`);
} else {
throw error;
}
}
}
}

Expand Down
Loading