chore(scaffolder): improve GitHub scaffolder actions code
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
@@ -227,6 +227,10 @@ export function createPublishGithubAction(options: {
|
||||
|
||||
const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError('Invalid repository owner provided in repoUrl');
|
||||
}
|
||||
|
||||
const octokitOptions = await getOctokitOptions({
|
||||
integrations,
|
||||
credentialsProvider: githubCredentialsProvider,
|
||||
@@ -237,10 +241,6 @@ export function createPublishGithubAction(options: {
|
||||
});
|
||||
const client = new Octokit(octokitOptions);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError('Invalid repository owner provided in repoUrl');
|
||||
}
|
||||
|
||||
const newRepo = await createGithubRepoWithCollaboratorsAndTopics(
|
||||
client,
|
||||
repo,
|
||||
|
||||
@@ -117,6 +117,10 @@ export function createGithubBranchProtectionAction(options: {
|
||||
|
||||
const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError(`No owner provided for repo ${repoUrl}`);
|
||||
}
|
||||
|
||||
const octokitOptions = await getOctokitOptions({
|
||||
integrations,
|
||||
token: providedToken,
|
||||
@@ -126,10 +130,6 @@ export function createGithubBranchProtectionAction(options: {
|
||||
});
|
||||
const client = new Octokit(octokitOptions);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError(`No owner provided for repo ${repoUrl}`);
|
||||
}
|
||||
|
||||
const repository = await client.rest.repos.get({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
|
||||
@@ -109,6 +109,10 @@ export function createGithubDeployKeyAction(options: {
|
||||
|
||||
const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError(`No owner provided for repo ${repoUrl}`);
|
||||
}
|
||||
|
||||
const octokitOptions = await getOctokitOptions({
|
||||
integrations,
|
||||
token: providedToken,
|
||||
@@ -117,10 +121,6 @@ export function createGithubDeployKeyAction(options: {
|
||||
repo,
|
||||
});
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError(`No owner provided for repo ${repoUrl}`);
|
||||
}
|
||||
|
||||
const client = new Octokit(octokitOptions);
|
||||
|
||||
await client.rest.repos.createDeployKey({
|
||||
|
||||
@@ -177,6 +177,10 @@ export function createGithubEnvironmentAction(options: {
|
||||
|
||||
const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError(`No owner provided for repo ${repoUrl}`);
|
||||
}
|
||||
|
||||
const octokitOptions = await getOctokitOptions({
|
||||
integrations,
|
||||
token: providedToken,
|
||||
@@ -185,10 +189,6 @@ export function createGithubEnvironmentAction(options: {
|
||||
repo,
|
||||
});
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError(`No owner provided for repo ${repoUrl}`);
|
||||
}
|
||||
|
||||
const client = new Octokit(octokitOptions);
|
||||
const repository = await client.rest.repos.get({
|
||||
owner: owner,
|
||||
|
||||
@@ -94,6 +94,10 @@ export function createGithubPagesEnableAction(options: {
|
||||
|
||||
const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError('Invalid repository owner provided in repoUrl');
|
||||
}
|
||||
|
||||
const octokitOptions = await getOctokitOptions({
|
||||
integrations,
|
||||
credentialsProvider: githubCredentialsProvider,
|
||||
@@ -104,10 +108,6 @@ export function createGithubPagesEnableAction(options: {
|
||||
});
|
||||
const client = new Octokit(octokitOptions);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError('Invalid repository owner provided in repoUrl');
|
||||
}
|
||||
|
||||
ctx.logger.info(
|
||||
`Attempting to enable GitHub Pages for ${owner}/${repo} with "${buildType}" build type, on source branch "${sourceBranch}" and source path "${sourcePath}"`,
|
||||
);
|
||||
|
||||
@@ -182,6 +182,10 @@ export function createGithubRepoCreateAction(options: {
|
||||
|
||||
const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError('Invalid repository owner provided in repoUrl');
|
||||
}
|
||||
|
||||
const octokitOptions = await getOctokitOptions({
|
||||
integrations,
|
||||
credentialsProvider: githubCredentialsProvider,
|
||||
@@ -192,10 +196,6 @@ export function createGithubRepoCreateAction(options: {
|
||||
});
|
||||
const client = new Octokit(octokitOptions);
|
||||
|
||||
if (!owner) {
|
||||
throw new InputError('Invalid repository owner provided in repoUrl');
|
||||
}
|
||||
|
||||
const newRepo = await createGithubRepoWithCollaboratorsAndTopics(
|
||||
client,
|
||||
repo,
|
||||
|
||||
Reference in New Issue
Block a user