fix(backend-github): fail workflow migrations gracefully (#3325)

* fix(backend-github): fail workflow migrations gracefully

* fix: formatting
This commit is contained in:
Shawn Erquhart 2020-02-25 16:25:37 -05:00 committed by GitHub
parent 8874769b31
commit 83e0383b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -680,6 +680,7 @@ export default class API {
if (!branch) {
await this.createBranch(newBranchName, pullRequest.head.sha as string);
}
const pr =
(await this.getPullRequests(newBranchName, PullRequestState.All, () => true))[0] ||
(await this.createPR(pullRequest.title, newBranchName));
@ -725,7 +726,13 @@ export default class API {
if (!metadata.version) {
console.log(`Migrating Pull Request '${number}' to version 1`);
// migrate branch from cms/slug to cms/collection/slug
try {
({ metadata, pullRequest } = await this.migrateToVersion1(pullRequest, metadata));
} catch (e) {
console.log(`Failed to migrate Pull Request '${number}' to version 1. See error below.`);
console.error(e);
return;
}
newNumber = pullRequest.number;
console.log(
`Done migrating Pull Request '${number}' to version 1. New pull request '${newNumber}' created.`,