Skip to content

Commit

Permalink
fix(backend-github): fail workflow migrations gracefully (#3325)
Browse files Browse the repository at this point in the history
* fix(backend-github): fail workflow migrations gracefully

* fix: formatting
  • Loading branch information
erquhart committed Feb 25, 2020
1 parent 8874769 commit 83e0383
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/netlify-cms-backend-github/src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
({ metadata, pullRequest } = await this.migrateToVersion1(pullRequest, metadata));
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.`,
Expand Down

0 comments on commit 83e0383

Please sign in to comment.