diff --git a/.changeset/spotty-goats-look.md b/.changeset/spotty-goats-look.md new file mode 100644 index 0000000000..0759afcd57 --- /dev/null +++ b/.changeset/spotty-goats-look.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Adds more of an explanation when the `publish:github` scaffolder action fails to create a repository. diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts index 340eb06dcd..1f9125d962 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts @@ -263,7 +263,22 @@ export function createPublishGithubAction(options: { allow_rebase_merge: allowRebaseMerge, }); - const { data: newRepo } = await repoCreationPromise; + let newRepo; + + try { + newRepo = (await repoCreationPromise).data; + } catch (e) { + assertError(e); + if (e.message === 'Resource not accessible by integration') { + ctx.logger.warn( + `The GitHub app or token provided may not have the required permissions to create the ${user.data.type} repository ${owner}/${repo}.`, + ); + } + throw new Error( + `Failed to create the ${user.data.type} repository ${owner}/${repo}, ${e.message}`, + ); + } + if (access?.startsWith(`${owner}/`)) { const [, team] = access.split('/'); await client.rest.teams.addOrUpdateRepoPermissionsInOrg({