From 7c2eec68a609c48b21aee537020a00d6d5884891 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Tue, 17 May 2022 18:43:38 +0100 Subject: [PATCH] more verbose logging on publish:github error Signed-off-by: Brian Fletcher --- .../actions/builtin/publish/github.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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..2e5fc2091f 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 to Backstage may not have the required permissions to create the repository.', + ); + } + 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({