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
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as ActionUtils from '@github/libs/ActionUtils';
import CONST from '@github/libs/CONST';
import GithubUtils from '@github/libs/GithubUtils';
import {RequestError} from '@octokit/types';

Check failure on line 7 in .github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

All imports in the declaration are only used as types. Use `import type`

type PlatformResult = 'success' | 'cancelled' | 'skipped' | 'failure';

Expand Down Expand Up @@ -113,16 +114,24 @@
* 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