more verbose logging on publish:github error

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2022-05-17 18:43:38 +01:00
parent 1b1b7d7201
commit 7c2eec68a6
@@ -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({