chore: use new actions format

Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
benjdlambert
2025-06-03 15:37:28 +02:00
parent 79e446d190
commit 575c76b13f
40 changed files with 1236 additions and 1515 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-github': patch
---
Migrate to using new actions
@@ -9,7 +9,6 @@ import { CatalogApi } from '@backstage/catalog-client';
import { Config } from '@backstage/config';
import { createPullRequest } from 'octokit-plugin-create-pull-request';
import { GithubCredentialsProvider } from '@backstage/integration';
import { JsonObject } from '@backstage/types';
import { Octokit } from 'octokit';
import { OctokitOptions } from '@octokit/core/dist-types/types';
import { ScmIntegrationRegistry } from '@backstage/integration';
@@ -25,13 +24,13 @@ export function createGithubActionsDispatchAction(options: {
repoUrl: string;
workflowId: string;
branchOrTagName: string;
workflowInputs?: {
[key: string]: string;
};
token?: string;
workflowInputs?: Record<string, string> | undefined;
token?: string | undefined;
},
JsonObject,
'v1'
{
[x: string]: any;
},
'v2'
>;
// @public
@@ -43,11 +42,13 @@ export function createGithubAutolinksAction(options: {
repoUrl: string;
keyPrefix: string;
urlTemplate: string;
isAlphanumeric?: boolean;
token?: string;
isAlphanumeric?: boolean | undefined;
token?: string | undefined;
},
JsonObject,
'v1'
{
[x: string]: any;
},
'v2'
>;
// @public
@@ -56,35 +57,37 @@ export function createGithubBranchProtectionAction(options: {
}): TemplateAction<
{
repoUrl: string;
branch?: string;
enforceAdmins?: boolean;
requiredApprovingReviewCount?: number;
requireCodeOwnerReviews?: boolean;
dismissStaleReviews?: boolean;
branch?: string | undefined;
enforceAdmins?: boolean | undefined;
requiredApprovingReviewCount?: number | undefined;
requireCodeOwnerReviews?: boolean | undefined;
dismissStaleReviews?: boolean | undefined;
bypassPullRequestAllowances?:
| {
users?: string[];
teams?: string[];
apps?: string[];
apps?: string[] | undefined;
teams?: string[] | undefined;
users?: string[] | undefined;
}
| undefined;
restrictions?:
| {
users: string[];
teams: string[];
apps?: string[];
users: string[];
apps?: string[] | undefined;
}
| undefined;
requiredStatusCheckContexts?: string[];
requireBranchesToBeUpToDate?: boolean;
requiredConversationResolution?: boolean;
requireLastPushApproval?: boolean;
requiredCommitSigning?: boolean;
requiredLinearHistory?: boolean;
token?: string;
requiredStatusCheckContexts?: string[] | undefined;
requireBranchesToBeUpToDate?: boolean | undefined;
requiredConversationResolution?: boolean | undefined;
requireLastPushApproval?: boolean | undefined;
requiredCommitSigning?: boolean | undefined;
requiredLinearHistory?: boolean | undefined;
token?: string | undefined;
},
JsonObject,
'v1'
{
[x: string]: any;
},
'v2'
>;
// @public
@@ -96,11 +99,13 @@ export function createGithubDeployKeyAction(options: {
publicKey: string;
privateKey: string;
deployKeyName: string;
privateKeySecretName?: string;
token?: string;
privateKeySecretName?: string | undefined;
token?: string | undefined;
},
JsonObject,
'v1'
{
privateKeySecretName: string;
},
'v2'
>;
// @public
@@ -112,25 +117,25 @@ export function createGithubEnvironmentAction(options: {
{
repoUrl: string;
name: string;
deploymentBranchPolicy?: {
protected_branches: boolean;
custom_branch_policies: boolean;
};
customBranchPolicyNames?: string[];
customTagPolicyNames?: string[];
environmentVariables?: {
[key: string]: string;
};
secrets?: {
[key: string]: string;
};
token?: string;
waitTimer?: number;
preventSelfReview?: boolean;
reviewers?: string[];
deploymentBranchPolicy?:
| {
protected_branches: boolean;
custom_branch_policies: boolean;
}
| undefined;
customBranchPolicyNames?: string[] | undefined;
customTagPolicyNames?: string[] | undefined;
environmentVariables?: Record<string, string> | undefined;
secrets?: Record<string, string> | undefined;
token?: string | undefined;
waitTimer?: number | undefined;
preventSelfReview?: boolean | undefined;
reviewers?: string[] | undefined;
},
JsonObject,
'v1'
{
[x: string]: any;
},
'v2'
>;
// @public
@@ -142,10 +147,12 @@ export function createGithubIssuesLabelAction(options: {
repoUrl: string;
number: number;
labels: string[];
token?: string;
token?: string | undefined;
},
JsonObject,
'v1'
{
[x: string]: any;
},
'v2'
>;
// @public
@@ -155,13 +162,15 @@ export function createGithubPagesEnableAction(options: {
}): TemplateAction<
{
repoUrl: string;
buildType?: 'legacy' | 'workflow';
sourceBranch?: string;
sourcePath?: '/' | '/docs';
token?: string;
buildType?: 'legacy' | 'workflow' | undefined;
sourceBranch?: string | undefined;
sourcePath?: '/' | '/docs' | undefined;
token?: string | undefined;
},
JsonObject,
'v1'
{
[x: string]: any;
},
'v2'
>;
// @public
@@ -198,73 +207,76 @@ export function createGithubRepoCreateAction(options: {
}): TemplateAction<
{
repoUrl: string;
description?: string;
homepage?: string;
access?: string;
deleteBranchOnMerge?: boolean;
gitAuthorName?: string;
gitAuthorEmail?: string;
allowRebaseMerge?: boolean;
allowSquashMerge?: boolean;
squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE';
squashMergeCommitMessage?: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK';
allowMergeCommit?: boolean;
allowAutoMerge?: boolean;
allowUpdateBranch?: boolean;
requireCodeOwnerReviews?: boolean;
bypassPullRequestAllowances?: {
users?: string[];
teams?: string[];
apps?: string[];
};
requiredApprovingReviewCount?: number;
restrictions?: {
users: string[];
teams: string[];
apps?: string[];
};
requiredStatusCheckContexts?: string[];
requireBranchesToBeUpToDate?: boolean;
requiredConversationResolution?: boolean;
repoVisibility?: 'private' | 'internal' | 'public';
collaborators?: Array<
description?: string | undefined;
homepage?: string | undefined;
access?: string | undefined;
requireCodeOwnerReviews?: boolean | undefined;
bypassPullRequestAllowances?:
| {
user: string;
access: string;
apps?: string[] | undefined;
teams?: string[] | undefined;
users?: string[] | undefined;
}
| undefined;
requiredApprovingReviewCount?: number | undefined;
restrictions?:
| {
team: string;
access: string;
teams: string[];
users: string[];
apps?: string[] | undefined;
}
| undefined;
requiredStatusCheckContexts?: string[] | undefined;
requireBranchesToBeUpToDate?: boolean | undefined;
requiredConversationResolution?: boolean | undefined;
repoVisibility?: 'internal' | 'private' | 'public' | undefined;
deleteBranchOnMerge?: boolean | undefined;
allowMergeCommit?: boolean | undefined;
allowSquashMerge?: boolean | undefined;
squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE' | undefined;
squashMergeCommitMessage?:
| 'PR_BODY'
| 'COMMIT_MESSAGES'
| 'BLANK'
| undefined;
allowRebaseMerge?: boolean | undefined;
allowAutoMerge?: boolean | undefined;
allowUpdateBranch?: boolean | undefined;
collaborators?:
| (
| {
user: string;
access: string;
}
| {
team: string;
access: string;
}
)[]
| undefined;
hasProjects?: boolean | undefined;
hasWiki?: boolean | undefined;
hasIssues?: boolean | undefined;
token?: string | undefined;
topics?: string[] | undefined;
repoVariables?: Record<string, string> | undefined;
secrets?: Record<string, string> | undefined;
oidcCustomization?:
| {
username: string;
access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
useDefault: boolean;
includeClaimKeys?: string[] | undefined;
}
>;
hasProjects?: boolean;
hasWiki?: boolean;
hasIssues?: boolean;
token?: string;
topics?: string[];
repoVariables?: {
[key: string]: string;
};
secrets?: {
[key: string]: string;
};
oidcCustomization?: {
useDefault: boolean;
includeClaimKeys?: string[];
};
requireCommitSigning?: boolean;
requiredLinearHistory?: boolean;
customProperties?: {
[key: string]: string;
};
subscribe?: boolean;
| undefined;
requiredCommitSigning?: boolean | undefined;
requiredLinearHistory?: boolean | undefined;
customProperties?: Record<string, string> | undefined;
subscribe?: boolean | undefined;
},
JsonObject,
'v1'
{
remoteUrl: string;
repoContentsUrl: string;
},
'v2'
>;
// @public
@@ -275,41 +287,44 @@ export function createGithubRepoPushAction(options: {
}): TemplateAction<
{
repoUrl: string;
description?: string;
defaultBranch?: string;
protectDefaultBranch?: boolean;
protectEnforceAdmins?: boolean;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
requireCodeOwnerReviews?: boolean;
dismissStaleReviews?: boolean;
requireCodeOwnerReviews?: boolean | undefined;
dismissStaleReviews?: boolean | undefined;
requiredStatusCheckContexts?: string[] | undefined;
bypassPullRequestAllowances?:
| {
users?: string[];
teams?: string[];
apps?: string[];
apps?: string[] | undefined;
teams?: string[] | undefined;
users?: string[] | undefined;
}
| undefined;
requiredApprovingReviewCount?: number;
requiredApprovingReviewCount?: number | undefined;
restrictions?:
| {
users: string[];
teams: string[];
apps?: string[];
users: string[];
apps?: string[] | undefined;
}
| undefined;
requiredStatusCheckContexts?: string[];
requireBranchesToBeUpToDate?: boolean;
requiredConversationResolution?: boolean;
sourcePath?: string;
token?: string;
requiredCommitSigning?: boolean;
requiredLinearHistory?: boolean;
requireLastPushApproval?: boolean;
requireBranchesToBeUpToDate?: boolean | undefined;
requiredConversationResolution?: boolean | undefined;
requireLastPushApproval?: boolean | undefined;
defaultBranch?: string | undefined;
protectDefaultBranch?: boolean | undefined;
protectEnforceAdmins?: boolean | undefined;
gitCommitMessage?: string | undefined;
gitAuthorName?: string | undefined;
gitAuthorEmail?: string | undefined;
sourcePath?: string | undefined;
token?: string | undefined;
requiredCommitSigning?: boolean | undefined;
requiredLinearHistory?: boolean | undefined;
},
JsonObject,
'v1'
{
remoteUrl: string;
repoContentsUrl: string;
commitHash: string;
},
'v2'
>;
// @public
@@ -321,15 +336,17 @@ export function createGithubWebhookAction(options: {
{
repoUrl: string;
webhookUrl: string;
webhookSecret?: string;
events?: string[];
active?: boolean;
contentType?: 'form' | 'json';
insecureSsl?: boolean;
token?: string;
webhookSecret?: string | undefined;
events?: string[] | '*'[] | undefined;
active?: boolean | undefined;
contentType?: 'form' | 'json' | undefined;
insecureSsl?: boolean | undefined;
token?: string | undefined;
},
JsonObject,
'v1'
{
[x: string]: any;
},
'v2'
>;
// @public
@@ -340,84 +357,86 @@ export function createPublishGithubAction(options: {
}): TemplateAction<
{
repoUrl: string;
description?: string;
homepage?: string;
access?: string;
defaultBranch?: string;
protectDefaultBranch?: boolean;
protectEnforceAdmins?: boolean;
deleteBranchOnMerge?: boolean;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
allowRebaseMerge?: boolean;
allowSquashMerge?: boolean;
squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE';
squashMergeCommitMessage?: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK';
allowMergeCommit?: boolean;
allowAutoMerge?: boolean;
allowUpdateBranch?: boolean;
sourcePath?: string;
description?: string | undefined;
homepage?: string | undefined;
access?: string | undefined;
bypassPullRequestAllowances?:
| {
users?: string[];
teams?: string[];
apps?: string[];
apps?: string[] | undefined;
teams?: string[] | undefined;
users?: string[] | undefined;
}
| undefined;
requiredApprovingReviewCount?: number;
requiredApprovingReviewCount?: number | undefined;
restrictions?:
| {
users: string[];
teams: string[];
apps?: string[];
users: string[];
apps?: string[] | undefined;
}
| undefined;
requireCodeOwnerReviews?: boolean;
dismissStaleReviews?: boolean;
requiredStatusCheckContexts?: string[];
requireBranchesToBeUpToDate?: boolean;
requiredConversationResolution?: boolean;
requireLastPushApproval?: boolean;
repoVisibility?: 'private' | 'internal' | 'public';
collaborators?: Array<
| {
user: string;
access: string;
}
| {
team: string;
access: string;
}
| {
username: string;
access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
}
>;
requireCodeOwnerReviews?: boolean | undefined;
dismissStaleReviews?: boolean | undefined;
requiredStatusCheckContexts?: string[] | undefined;
requireBranchesToBeUpToDate?: boolean | undefined;
requiredConversationResolution?: boolean | undefined;
requireLastPushApproval?: boolean | undefined;
repoVisibility?: 'internal' | 'private' | 'public' | undefined;
defaultBranch?: string | undefined;
protectDefaultBranch?: boolean | undefined;
protectEnforceAdmins?: boolean | undefined;
deleteBranchOnMerge?: boolean | undefined;
gitCommitMessage?: string | undefined;
gitAuthorName?: string | undefined;
gitAuthorEmail?: string | undefined;
allowMergeCommit?: boolean | undefined;
allowSquashMerge?: boolean | undefined;
squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE' | undefined;
squashMergeCommitMessage?:
| 'PR_BODY'
| 'COMMIT_MESSAGES'
| 'BLANK'
| undefined;
allowRebaseMerge?: boolean | undefined;
allowAutoMerge?: boolean | undefined;
allowUpdateBranch?: boolean | undefined;
sourcePath?: string | undefined;
collaborators?:
| (
| {
user: string;
access: string;
}
| {
team: string;
access: string;
}
)[]
| undefined;
hasProjects?: boolean | undefined;
hasWiki?: boolean | undefined;
hasIssues?: boolean | undefined;
token?: string;
topics?: string[];
repoVariables?: {
[key: string]: string;
};
secrets?: {
[key: string]: string;
};
oidcCustomization?: {
useDefault: boolean;
includeClaimKeys?: string[];
};
requiredCommitSigning?: boolean;
requiredLinearHistory?: boolean;
customProperties?: {
[key: string]: string;
};
subscribe?: boolean;
token?: string | undefined;
topics?: string[] | undefined;
repoVariables?: Record<string, string> | undefined;
secrets?: Record<string, string> | undefined;
oidcCustomization?:
| {
useDefault: boolean;
includeClaimKeys?: string[] | undefined;
}
| undefined;
requiredCommitSigning?: boolean | undefined;
requiredLinearHistory?: boolean | undefined;
customProperties?: Record<string, string> | undefined;
subscribe?: boolean | undefined;
},
JsonObject,
'v1'
{
remoteUrl: string;
repoContentsUrl: string;
commitHash: string;
},
'v2'
>;
// @public
@@ -425,28 +444,32 @@ export const createPublishGithubPullRequestAction: (
options: CreateGithubPullRequestActionOptions,
) => TemplateAction<
{
title: string;
branchName: string;
targetBranchName?: string;
description: string;
repoUrl: string;
draft?: boolean;
targetPath?: string;
sourcePath?: string;
token?: string;
reviewers?: string[];
assignees?: string[];
teamReviewers?: string[];
commitMessage?: string;
update?: boolean;
forceFork?: boolean;
gitAuthorName?: string;
gitAuthorEmail?: string;
forceEmptyGitAuthor?: boolean;
createWhenEmpty?: boolean;
branchName: string;
title: string;
description: string;
targetBranchName?: string | undefined;
draft?: boolean | undefined;
sourcePath?: string | undefined;
targetPath?: string | undefined;
token?: string | undefined;
reviewers?: string[] | undefined;
assignees?: string[] | undefined;
teamReviewers?: string[] | undefined;
commitMessage?: string | undefined;
update?: boolean | undefined;
forceFork?: boolean | undefined;
gitAuthorName?: string | undefined;
gitAuthorEmail?: string | undefined;
forceEmptyGitAuthor?: boolean | undefined;
createWhenEmpty?: boolean | undefined;
},
JsonObject,
'v1'
{
targetBranchName: string;
remoteUrl: string;
pullRequestNumber: number;
},
'v2'
>;
// @public
@@ -98,7 +98,7 @@ describe('publish:github', () => {
jest.requireActual('./helpers');
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -101,7 +101,7 @@ describe('publish:github', () => {
jest.requireActual('./gitHelpers');
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -605,6 +605,7 @@ describe('publish:github', () => {
const customAuthorIntegrations =
ScmIntegrations.fromConfig(customAuthorConfig);
const customAuthorAction = createPublishGithubAction({
integrations: customAuthorIntegrations,
config: customAuthorConfig,
@@ -47,140 +47,61 @@ export function createPublishGithubAction(options: {
}) {
const { integrations, config, githubCredentialsProvider } = options;
return createTemplateAction<{
repoUrl: string;
description?: string;
homepage?: string;
access?: string;
defaultBranch?: string;
protectDefaultBranch?: boolean;
protectEnforceAdmins?: boolean;
deleteBranchOnMerge?: boolean;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
allowRebaseMerge?: boolean;
allowSquashMerge?: boolean;
squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE';
squashMergeCommitMessage?: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK';
allowMergeCommit?: boolean;
allowAutoMerge?: boolean;
allowUpdateBranch?: boolean;
sourcePath?: string;
bypassPullRequestAllowances?:
| {
users?: string[];
teams?: string[];
apps?: string[];
}
| undefined;
requiredApprovingReviewCount?: number;
restrictions?:
| {
users: string[];
teams: string[];
apps?: string[];
}
| undefined;
requireCodeOwnerReviews?: boolean;
dismissStaleReviews?: boolean;
requiredStatusCheckContexts?: string[];
requireBranchesToBeUpToDate?: boolean;
requiredConversationResolution?: boolean;
requireLastPushApproval?: boolean;
repoVisibility?: 'private' | 'internal' | 'public';
collaborators?: Array<
| {
user: string;
access: string;
}
| {
team: string;
access: string;
}
| {
/** @deprecated This field is deprecated in favor of team */
username: string;
access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
}
>;
hasProjects?: boolean | undefined;
hasWiki?: boolean | undefined;
hasIssues?: boolean | undefined;
token?: string;
topics?: string[];
repoVariables?: { [key: string]: string };
secrets?: { [key: string]: string };
oidcCustomization?: {
useDefault: boolean;
includeClaimKeys?: string[];
};
requiredCommitSigning?: boolean;
requiredLinearHistory?: boolean;
customProperties?: { [key: string]: string };
subscribe?: boolean;
}>({
return createTemplateAction({
id: 'publish:github',
description:
'Initializes a git repository of contents in workspace and publishes it to GitHub.',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl'],
properties: {
repoUrl: inputProps.repoUrl,
description: inputProps.description,
homepage: inputProps.homepage,
access: inputProps.access,
bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,
requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,
restrictions: inputProps.restrictions,
requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,
dismissStaleReviews: inputProps.dismissStaleReviews,
requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,
requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,
requiredConversationResolution:
inputProps.requiredConversationResolution,
requireLastPushApproval: inputProps.requireLastPushApproval,
repoVisibility: inputProps.repoVisibility,
defaultBranch: inputProps.defaultBranch,
protectDefaultBranch: inputProps.protectDefaultBranch,
protectEnforceAdmins: inputProps.protectEnforceAdmins,
deleteBranchOnMerge: inputProps.deleteBranchOnMerge,
gitCommitMessage: inputProps.gitCommitMessage,
gitAuthorName: inputProps.gitAuthorName,
gitAuthorEmail: inputProps.gitAuthorEmail,
allowMergeCommit: inputProps.allowMergeCommit,
allowSquashMerge: inputProps.allowSquashMerge,
squashMergeCommitTitle: inputProps.squashMergeCommitTitle,
squashMergeCommitMessage: inputProps.squashMergeCommitMessage,
allowRebaseMerge: inputProps.allowRebaseMerge,
allowAutoMerge: inputProps.allowAutoMerge,
allowUpdateBranch: inputProps.allowUpdateBranch,
sourcePath: inputProps.sourcePath,
collaborators: inputProps.collaborators,
hasProjects: inputProps.hasProjects,
hasWiki: inputProps.hasWiki,
hasIssues: inputProps.hasIssues,
token: inputProps.token,
topics: inputProps.topics,
repoVariables: inputProps.repoVariables,
secrets: inputProps.secrets,
oidcCustomization: inputProps.oidcCustomization,
requiredCommitSigning: inputProps.requiredCommitSigning,
requiredLinearHistory: inputProps.requiredLinearHistory,
customProperties: inputProps.customProperties,
subscribe: inputProps.subscribe,
},
repoUrl: inputProps.repoUrl,
description: inputProps.description,
homepage: inputProps.homepage,
access: inputProps.access,
bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,
requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,
restrictions: inputProps.restrictions,
requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,
dismissStaleReviews: inputProps.dismissStaleReviews,
requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,
requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,
requiredConversationResolution:
inputProps.requiredConversationResolution,
requireLastPushApproval: inputProps.requireLastPushApproval,
repoVisibility: inputProps.repoVisibility,
defaultBranch: inputProps.defaultBranch,
protectDefaultBranch: inputProps.protectDefaultBranch,
protectEnforceAdmins: inputProps.protectEnforceAdmins,
deleteBranchOnMerge: inputProps.deleteBranchOnMerge,
gitCommitMessage: inputProps.gitCommitMessage,
gitAuthorName: inputProps.gitAuthorName,
gitAuthorEmail: inputProps.gitAuthorEmail,
allowMergeCommit: inputProps.allowMergeCommit,
allowSquashMerge: inputProps.allowSquashMerge,
squashMergeCommitTitle: inputProps.squashMergeCommitTitle,
squashMergeCommitMessage: inputProps.squashMergeCommitMessage,
allowRebaseMerge: inputProps.allowRebaseMerge,
allowAutoMerge: inputProps.allowAutoMerge,
allowUpdateBranch: inputProps.allowUpdateBranch,
sourcePath: inputProps.sourcePath,
collaborators: inputProps.collaborators,
hasProjects: inputProps.hasProjects,
hasWiki: inputProps.hasWiki,
hasIssues: inputProps.hasIssues,
token: inputProps.token,
topics: inputProps.topics,
repoVariables: inputProps.repoVariables,
secrets: inputProps.secrets,
oidcCustomization: inputProps.oidcCustomization,
requiredCommitSigning: inputProps.requiredCommitSigning,
requiredLinearHistory: inputProps.requiredLinearHistory,
customProperties: inputProps.customProperties,
subscribe: inputProps.subscribe,
},
output: {
type: 'object',
properties: {
remoteUrl: outputProps.remoteUrl,
repoContentsUrl: outputProps.repoContentsUrl,
commitHash: outputProps.commitHash,
},
remoteUrl: outputProps.remoteUrl,
repoContentsUrl: outputProps.repoContentsUrl,
commitHash: outputProps.commitHash,
},
},
async handler(ctx) {
@@ -53,7 +53,7 @@ describe('github:actions:dispatch', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -50,7 +50,7 @@ describe('github:actions:dispatch', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -37,52 +37,41 @@ export function createGithubActionsDispatchAction(options: {
}) {
const { integrations, githubCredentialsProvider } = options;
return createTemplateAction<{
repoUrl: string;
workflowId: string;
branchOrTagName: string;
workflowInputs?: { [key: string]: string };
token?: string;
}>({
return createTemplateAction({
id: 'github:actions:dispatch',
description:
'Dispatches a GitHub Action workflow for a given branch or tag',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl', 'workflowId', 'branchOrTagName'],
properties: {
repoUrl: {
title: 'Repository Location',
repoUrl: z =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',
type: 'string',
},
workflowId: {
title: 'Workflow ID',
}),
workflowId: z =>
z.string({
description: 'The GitHub Action Workflow filename',
type: 'string',
},
branchOrTagName: {
title: 'Branch or Tag name',
}),
branchOrTagName: z =>
z.string({
description:
'The git branch or tag name used to dispatch the workflow',
type: 'string',
},
workflowInputs: {
title: 'Workflow Inputs',
description:
'Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10. ',
type: 'object',
},
token: {
title: 'Authentication Token',
type: 'string',
description:
'The `GITHUB_TOKEN` to use for authorization to GitHub',
},
},
}),
workflowInputs: z =>
z
.record(z.string(), {
description:
'Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10.',
})
.optional(),
token: z =>
z
.string({
description:
'The `GITHUB_TOKEN` to use for authorization to GitHub',
})
.optional(),
},
},
async handler(ctx) {
@@ -53,7 +53,7 @@ describe('github:autolinks:create', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any, any>;
let action: TemplateAction<any, any, any>;
const input = yaml.parse(examples[0].example).steps[0].input;
const mockContext = createMockActionContext({
input,
@@ -51,7 +51,7 @@ describe('github:autolinks:create', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any, any>;
let action: TemplateAction<any, any, any>;
const workspacePath = createMockDirectory().resolve('workspace');
it('should pass context logger to Octokit client', async () => {
@@ -37,52 +37,41 @@ export function createGithubAutolinksAction(options: {
}) {
const { integrations, githubCredentialsProvider } = options;
return createTemplateAction<{
repoUrl: string;
keyPrefix: string;
urlTemplate: string;
isAlphanumeric?: boolean;
token?: string;
}>({
return createTemplateAction({
id: 'github:autolinks:create',
description: 'Create an autolink reference for a repository',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl', 'keyPrefix', 'urlTemplate'],
properties: {
repoUrl: {
title: 'Repository Location',
repoUrl: z =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',
type: 'string',
},
keyPrefix: {
title: 'Key Prefix',
}),
keyPrefix: z =>
z.string({
description:
'This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.',
type: 'string',
},
urlTemplate: {
title: 'URL Template',
}),
urlTemplate: z =>
z.string({
description:
'The URL must contain `<num>` for the reference number. `<num>` matches different characters depending on the value of isAlphanumeric.',
type: 'string',
},
isAlphanumeric: {
title: 'Alphanumeric',
description:
'Whether this autolink reference matches alphanumeric characters. If `true`, the `<num>` parameter of the `url_template` matches alphanumeric characters `A-Z` (case insensitive), `0-9`, and `-`. If `false`, this autolink reference only matches numeric characters. Default: `true`',
type: 'boolean',
default: true,
},
token: {
title: 'Authentication Token',
type: 'string',
description: 'The token to use for authorization to GitHub',
},
},
}),
isAlphanumeric: z =>
z
.boolean({
description:
'Whether this autolink reference matches alphanumeric characters. If `true`, the `<num>` parameter of the `url_template` matches alphanumeric characters `A-Z` (case insensitive), `0-9`, and `-`. If `false`, this autolink reference only matches numeric characters. Default: `true`',
})
.default(true)
.optional(),
token: z =>
z
.string({
description: 'The token to use for authorization to GitHub',
})
.optional(),
},
},
async handler(ctx) {
@@ -50,7 +50,7 @@ describe('github:branch-protection:create', () => {
});
const integrations = ScmIntegrations.fromConfig(config);
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -47,7 +47,7 @@ describe('github:branch-protection:create', () => {
});
const integrations = ScmIntegrations.fromConfig(config);
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -36,64 +36,28 @@ export function createGithubBranchProtectionAction(options: {
}) {
const { integrations } = options;
return createTemplateAction<{
repoUrl: string;
branch?: string;
enforceAdmins?: boolean;
requiredApprovingReviewCount?: number;
requireCodeOwnerReviews?: boolean;
dismissStaleReviews?: boolean;
bypassPullRequestAllowances?:
| {
users?: string[];
teams?: string[];
apps?: string[];
}
| undefined;
restrictions?:
| {
users: string[];
teams: string[];
apps?: string[];
}
| undefined;
requiredStatusCheckContexts?: string[];
requireBranchesToBeUpToDate?: boolean;
requiredConversationResolution?: boolean;
requireLastPushApproval?: boolean;
requiredCommitSigning?: boolean;
requiredLinearHistory?: boolean;
token?: string;
}>({
return createTemplateAction({
id: 'github:branch-protection:create',
description: 'Configures Branch Protection',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl'],
properties: {
repoUrl: inputProps.repoUrl,
branch: {
title: 'Branch name',
description: `The branch to protect. Defaults to the repository's default branch`,
type: 'string',
},
enforceAdmins: inputProps.protectEnforceAdmins,
requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,
requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,
dismissStaleReviews: inputProps.dismissStaleReviews,
bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,
restrictions: inputProps.restrictions,
requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,
requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,
requiredConversationResolution:
inputProps.requiredConversationResolution,
requireLastPushApproval: inputProps.requireLastPushApproval,
requiredCommitSigning: inputProps.requiredCommitSigning,
requiredLinearHistory: inputProps.requiredLinearHistory,
token: inputProps.token,
},
repoUrl: inputProps.repoUrl,
branch: inputProps.branch,
enforceAdmins: inputProps.protectEnforceAdmins,
requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,
requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,
dismissStaleReviews: inputProps.dismissStaleReviews,
bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,
restrictions: inputProps.restrictions,
requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,
requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,
requiredConversationResolution:
inputProps.requiredConversationResolution,
requireLastPushApproval: inputProps.requireLastPushApproval,
requiredCommitSigning: inputProps.requiredCommitSigning,
requiredLinearHistory: inputProps.requiredLinearHistory,
token: inputProps.token,
},
},
async handler(ctx) {
@@ -52,7 +52,7 @@ describe('Usage examples', () => {
},
});
const integrations = ScmIntegrations.fromConfig(config);
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext();
@@ -51,7 +51,7 @@ describe('github:deployKey:create', () => {
});
const integrations = ScmIntegrations.fromConfig(config);
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -36,65 +36,50 @@ export function createGithubDeployKeyAction(options: {
const { integrations } = options;
// For more information on how to define custom actions, see
// https://backstage.io/docs/features/software-templates/writing-custom-actions
return createTemplateAction<{
repoUrl: string;
publicKey: string;
privateKey: string;
deployKeyName: string;
privateKeySecretName?: string;
token?: string;
}>({
return createTemplateAction({
id: 'github:deployKey:create',
description: 'Creates and stores Deploy Keys',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl', 'publicKey', 'privateKey', 'deployKeyName'],
properties: {
repoUrl: {
title: 'Repository Location',
repoUrl: z =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',
type: 'string',
},
publicKey: {
title: 'SSH Public Key',
}),
publicKey: z =>
z.string({
description:
'Generated from `ssh-keygen`. Begins with `ssh-rsa`, `ecdsa-sha2-nistp256`, `ecdsa-sha2-nistp384`, `ecdsa-sha2-nistp521`, `ssh-ed25519`, `sk-ecdsa-sha2-nistp256@openssh.com`, or `sk-ssh-ed25519@openssh.com`.',
type: 'string',
},
privateKey: {
title: 'SSH Private Key',
}),
privateKey: z =>
z.string({
description: 'SSH Private Key generated from `ssh-keygen`',
type: 'string',
},
deployKeyName: {
title: 'Deploy Key Name',
}),
deployKeyName: z =>
z.string({
description: `Name of the Deploy Key`,
type: 'string',
},
privateKeySecretName: {
title: 'Private Key GitHub Secret Name',
description:
'Name of the GitHub Secret to store the private key related to the Deploy Key. Defaults to: `KEY_NAME_PRIVATE_KEY` where `KEY_NAME` is the name of the Deploy Key',
type: 'string',
},
token: {
title: 'Authentication Token',
type: 'string',
description: 'The token to use for authorization to GitHub',
},
},
}),
privateKeySecretName: z =>
z
.string({
description:
'Name of the GitHub Secret to store the private key related to the Deploy Key. Defaults to: `KEY_NAME_PRIVATE_KEY` where `KEY_NAME` is the name of the Deploy Key',
})
.optional(),
token: z =>
z
.string({
description: 'The token to use for authorization to GitHub',
})
.optional(),
},
output: {
type: 'object',
properties: {
privateKeySecretName: {
title: 'The GitHub Action Repo Secret Name for the Private Key',
type: 'string',
},
},
privateKeySecretName: z =>
z.string({
description:
'The GitHub Action Repo Secret Name for the Private Key',
}),
},
},
async handler(ctx) {
@@ -69,7 +69,7 @@ describe('github:environment:create examples', () => {
});
const integrations = ScmIntegrations.fromConfig(config);
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext();
@@ -80,7 +80,7 @@ describe('github:environment:create', () => {
targetPluginId: 'catalog',
});
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -41,118 +41,95 @@ export function createGithubEnvironmentAction(options: {
const { integrations, catalogClient, auth } = options;
// For more information on how to define custom actions, see
// https://backstage.io/docs/features/software-templates/writing-custom-actions
return createTemplateAction<{
repoUrl: string;
name: string;
deploymentBranchPolicy?: {
protected_branches: boolean;
custom_branch_policies: boolean;
};
customBranchPolicyNames?: string[];
customTagPolicyNames?: string[];
environmentVariables?: { [key: string]: string };
secrets?: { [key: string]: string };
token?: string;
waitTimer?: number;
preventSelfReview?: boolean;
reviewers?: string[];
}>({
return createTemplateAction({
id: 'github:environment:create',
description: 'Creates Deployment Environments',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl', 'name'],
properties: {
repoUrl: {
title: 'Repository Location',
repoUrl: z =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',
type: 'string',
},
name: {
title: 'Environment Name',
}),
name: z =>
z.string({
description: `Name of the deployment environment to create`,
type: 'string',
},
deploymentBranchPolicy: {
title: 'Deployment Branch Policy',
description:
'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',
type: 'object',
required: ['protected_branches', 'custom_branch_policies'],
properties: {
protected_branches: {
title: 'Protected Branches',
description:
'Whether only branches with branch protection rules can deploy to this environment. If `protected_branches` is `true`, `custom_branch_policies` must be `false`; if `protected_branches` is `false`, `custom_branch_policies` must be `true`.',
type: 'boolean',
}),
deploymentBranchPolicy: z =>
z
.object(
{
protected_branches: z.boolean({
description:
'Whether only branches with branch protection rules can deploy to this environment. If `protected_branches` is `true`, `custom_branch_policies` must be `false`; if `protected_branches` is `false`, `custom_branch_policies` must be `true`.',
}),
custom_branch_policies: z.boolean({
description:
'Whether only branches that match the specified name patterns can deploy to this environment. If `custom_branch_policies` is `true`, `protected_branches` must be `false`; if `custom_branch_policies` is `false`, `protected_branches` must be `true`.',
}),
},
custom_branch_policies: {
title: 'Custom Branch Policies',
{
description:
'Whether only branches that match the specified name patterns can deploy to this environment. If `custom_branch_policies` is `true`, `protected_branches` must be `false`; if `custom_branch_policies` is `false`, `protected_branches` must be `true`.',
type: 'boolean',
'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',
},
},
},
customBranchPolicyNames: {
title: 'Custom Branch Policy Name',
description: `The name pattern that branches must match in order to deploy to the environment.
)
.optional(),
customBranchPolicyNames: z =>
z
.array(z.string(), {
description: `The name pattern that branches must match in order to deploy to the environment.
Wildcard characters will not match \`/\`. For example, to match branches that begin with \`release/\` and contain an additional single slash, use \`release/*/*\`. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
type: 'array',
items: {
type: 'string',
},
},
customTagPolicyNames: {
title: 'Custom Tag Policy Name',
description: `The name pattern that tags must match in order to deploy to the environment.
})
.optional(),
customTagPolicyNames: z =>
z
.array(z.string(), {
description: `The name pattern that tags must match in order to deploy to the environment.
Wildcard characters will not match \`/\`. For example, to match tags that begin with \`release/\` and contain an additional single slash, use \`release/*/*\`. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
type: 'array',
items: {
type: 'string',
},
},
environmentVariables: {
title: 'Environment Variables',
description: `Environment variables attached to the deployment environment`,
type: 'object',
},
secrets: {
title: 'Deployment Secrets',
description: `Secrets attached to the deployment environment`,
type: 'object',
},
token: {
title: 'Authentication Token',
type: 'string',
description: 'The token to use for authorization to GitHub',
},
waitTimer: {
title: 'Wait Timer',
type: 'integer',
description:
'The time to wait before creating or updating the environment (in milliseconds)',
},
preventSelfReview: {
title: 'Prevent Self Review',
type: 'boolean',
description: 'Whether to prevent self-review for this environment',
},
reviewers: {
title: 'Reviewers',
type: 'array',
description:
'Reviewers for this environment. Must be a list of Backstage entity references.',
items: {
type: 'string',
},
},
},
})
.optional(),
environmentVariables: z =>
z
.record(z.string(), {
description: `Environment variables attached to the deployment environment`,
})
.optional(),
secrets: z =>
z
.record(z.string(), {
description: `Secrets attached to the deployment environment`,
})
.optional(),
token: z =>
z
.string({
description: 'The token to use for authorization to GitHub',
})
.optional(),
waitTimer: z =>
z
.number({
description:
'The time to wait before creating or updating the environment (in milliseconds)',
})
.optional(),
preventSelfReview: z =>
z
.boolean({
description:
'Whether to prevent self-review for this environment',
})
.optional(),
reviewers: z =>
z
.array(z.string(), {
description:
'Reviewers for this environment. Must be a list of Backstage entity references.',
})
.optional(),
},
},
async handler(ctx) {
@@ -61,7 +61,7 @@ describe('github:issues:label examples', () => {
const getOctokitOptionsMock = getOctokitOptions as jest.Mock;
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext();
@@ -58,7 +58,7 @@ describe('github:issues:label', () => {
const getOctokitOptionsMock = getOctokitOptions as jest.Mock;
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -37,46 +37,32 @@ export function createGithubIssuesLabelAction(options: {
}) {
const { integrations, githubCredentialsProvider } = options;
return createTemplateAction<{
repoUrl: string;
number: number;
labels: string[];
token?: string;
}>({
return createTemplateAction({
id: 'github:issues:label',
description: 'Adds labels to a pull request or issue on GitHub.',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl', 'number', 'labels'],
properties: {
repoUrl: {
title: 'Repository Location',
repoUrl: z =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',
type: 'string',
},
number: {
title: 'Pull Request or issue number',
}),
number: z =>
z.number({
description: 'The pull request or issue number to add labels to',
type: 'number',
},
labels: {
title: 'Labels',
}),
labels: z =>
z.array(z.string(), {
description: 'The labels to add to the pull request or issue',
type: 'array',
items: {
type: 'string',
},
},
token: {
title: 'Authentication Token',
type: 'string',
description:
'The `GITHUB_TOKEN` to use for authorization to GitHub',
},
},
}),
token: z =>
z
.string({
description:
'The `GITHUB_TOKEN` to use for authorization to GitHub',
})
.optional(),
},
},
async handler(ctx) {
@@ -50,7 +50,7 @@ describe('github:pages', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -48,7 +48,7 @@ describe('github:pages', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -38,55 +38,46 @@ export function createGithubPagesEnableAction(options: {
}) {
const { integrations, githubCredentialsProvider } = options;
return createTemplateAction<{
repoUrl: string;
buildType?: 'legacy' | 'workflow';
sourceBranch?: string;
sourcePath?: '/' | '/docs';
token?: string;
}>({
return createTemplateAction({
id: 'github:pages:enable',
examples,
description: 'Enables GitHub Pages for a repository.',
schema: {
input: {
type: 'object',
required: ['repoUrl'],
properties: {
repoUrl: {
title: 'Repository Location',
repoUrl: z =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',
type: 'string',
},
buildType: {
title: 'Build Type',
type: 'string',
default: 'workflow',
description:
'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',
enum: ['legacy', 'workflow'],
},
sourceBranch: {
title: 'Source Branch',
type: 'string',
default: 'main',
description: 'The GitHub Pages source branch. Default is "main"',
},
sourcePath: {
title: 'Source Path',
type: 'string',
default: '/',
description:
'The GitHub Pages source path - "/" or "/docs". Default is "/"',
enum: ['/', '/docs'],
},
token: {
title: 'Authorization Token',
type: 'string',
description: 'The token to use for authorization to GitHub',
},
},
}),
buildType: z =>
z
.enum(['legacy', 'workflow'], {
description:
'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',
})
.default('workflow')
.optional(),
sourceBranch: z =>
z
.string({
description: 'The GitHub Pages source branch. Default is "main"',
})
.default('main')
.optional(),
sourcePath: z =>
z
.enum(['/', '/docs'], {
description:
'The GitHub Pages source path - "/" or "/docs". Default is "/"',
})
.default('/')
.optional(),
token: z =>
z
.string({
description: 'The token to use for authorization to GitHub',
})
.optional(),
},
},
async handler(ctx) {
@@ -57,7 +57,7 @@ describe('publish:github:pull-request examples', () => {
});
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext();
let fakeClient: {
@@ -30,12 +30,12 @@ import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-
type GithubPullRequestActionInput = ReturnType<
typeof createPublishGithubPullRequestAction
> extends TemplateAction<infer U>
> extends TemplateAction<infer U, any, any>
? U
: never;
describe('createPublishGithubPullRequestAction', () => {
let instance: TemplateAction<GithubPullRequestActionInput>;
let instance: TemplateAction<GithubPullRequestActionInput, any, any>;
let fakeClient: {
createPullRequest: jest.Mock;
rest: {
@@ -128,169 +128,141 @@ export const createPublishGithubPullRequestAction = (
config,
} = options;
return createTemplateAction<{
title: string;
branchName: string;
targetBranchName?: string;
description: string;
repoUrl: string;
draft?: boolean;
targetPath?: string;
sourcePath?: string;
token?: string;
reviewers?: string[];
assignees?: string[];
teamReviewers?: string[];
commitMessage?: string;
update?: boolean;
forceFork?: boolean;
gitAuthorName?: string;
gitAuthorEmail?: string;
forceEmptyGitAuthor?: boolean;
createWhenEmpty?: boolean;
}>({
return createTemplateAction({
id: 'publish:github:pull-request',
examples,
supportsDryRun: true,
schema: {
input: {
required: ['repoUrl', 'title', 'description', 'branchName'],
type: 'object',
properties: {
repoUrl: {
title: 'Repository Location',
repoUrl: z =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',
type: 'string',
},
branchName: {
type: 'string',
title: 'Branch Name',
}),
branchName: z =>
z.string({
description: 'The name for the branch',
},
targetBranchName: {
type: 'string',
title: 'Target Branch Name',
description: 'The target branch name of the pull request',
},
title: {
type: 'string',
title: 'Pull Request Name',
}),
targetBranchName: z =>
z
.string({
description: 'The target branch name of the pull request',
})
.optional(),
title: z =>
z.string({
description: 'The name for the pull request',
},
description: {
type: 'string',
title: 'Pull Request Description',
}),
description: z =>
z.string({
description: 'The description of the pull request',
},
draft: {
type: 'boolean',
title: 'Create as Draft',
description: 'Create a draft pull request',
},
sourcePath: {
type: 'string',
title: 'Working Subdirectory',
description:
'Subdirectory of working directory to copy changes from',
},
targetPath: {
type: 'string',
title: 'Repository Subdirectory',
description: 'Subdirectory of repository to apply changes to',
},
token: {
title: 'Authentication Token',
type: 'string',
description: 'The token to use for authorization to GitHub',
},
reviewers: {
title: 'Pull Request Reviewers',
type: 'array',
items: {
type: 'string',
},
description:
'The users that will be added as reviewers to the pull request',
},
assignees: {
title: 'Pull Request Assignees',
type: 'array',
items: {
type: 'string',
},
description:
'The users that will be added as assignees to the pull request',
},
teamReviewers: {
title: 'Pull Request Team Reviewers',
type: 'array',
items: {
type: 'string',
},
description:
'The teams that will be added as reviewers to the pull request',
},
commitMessage: {
type: 'string',
title: 'Commit Message',
description: 'The commit message for the pull request commit',
},
update: {
type: 'boolean',
title: 'Update',
description: 'Update pull request if already exists',
},
forceFork: {
type: 'boolean',
title: 'Force Fork',
description: 'Create pull request from a fork',
},
gitAuthorName: {
type: 'string',
title: 'Default Author Name',
description:
'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',
},
gitAuthorEmail: {
type: 'string',
title: 'Default Author Email',
description:
'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',
},
forceEmptyGitAuthor: {
type: 'boolean',
title: 'Force Empty Git Author',
description:
'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',
},
createWhenEmpty: {
type: 'boolean',
title: 'Create When Empty',
description:
'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',
},
},
}),
draft: z =>
z
.boolean({
description: 'Create a draft pull request',
})
.optional(),
sourcePath: z =>
z
.string({
description:
'Subdirectory of working directory to copy changes from',
})
.optional(),
targetPath: z =>
z
.string({
description: 'Subdirectory of repository to apply changes to',
})
.optional(),
token: z =>
z
.string({
description: 'The token to use for authorization to GitHub',
})
.optional(),
reviewers: z =>
z
.array(z.string(), {
description:
'The users that will be added as reviewers to the pull request',
})
.optional(),
assignees: z =>
z
.array(z.string(), {
description:
'The users that will be added as assignees to the pull request',
})
.optional(),
teamReviewers: z =>
z
.array(z.string(), {
description:
'The teams that will be added as reviewers to the pull request',
})
.optional(),
commitMessage: z =>
z
.string({
description: 'The commit message for the pull request commit',
})
.optional(),
update: z =>
z
.boolean({
description: 'Update pull request if already exists',
})
.optional(),
forceFork: z =>
z
.boolean({
description: 'Create pull request from a fork',
})
.optional(),
gitAuthorName: z =>
z
.string({
description:
'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',
})
.optional(),
gitAuthorEmail: z =>
z
.string({
description:
'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',
})
.optional(),
forceEmptyGitAuthor: z =>
z
.boolean({
description:
'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',
})
.optional(),
createWhenEmpty: z =>
z
.boolean({
description:
'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',
})
.optional(),
},
output: {
required: [],
type: 'object',
properties: {
targetBranchName: {
title: 'Target branch name of the merge request',
type: 'string',
},
remoteUrl: {
type: 'string',
title: 'Pull Request URL',
targetBranchName: z =>
z.string({
description: 'Target branch name of the merge request',
}),
remoteUrl: z =>
z.string({
description: 'Link to the pull request in Github',
},
pullRequestNumber: {
type: 'number',
title: 'Pull Request Number',
}),
pullRequestNumber: z =>
z.number({
description: 'The pull request number',
},
},
}),
},
},
async handler(ctx) {
@@ -80,7 +80,7 @@ describe('github:repo:create examples', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -80,7 +80,7 @@ describe('github:repo:create', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -41,118 +41,50 @@ export function createGithubRepoCreateAction(options: {
}) {
const { integrations, githubCredentialsProvider } = options;
return createTemplateAction<{
repoUrl: string;
description?: string;
homepage?: string;
access?: string;
deleteBranchOnMerge?: boolean;
gitAuthorName?: string;
gitAuthorEmail?: string;
allowRebaseMerge?: boolean;
allowSquashMerge?: boolean;
squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE';
squashMergeCommitMessage?: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK';
allowMergeCommit?: boolean;
allowAutoMerge?: boolean;
allowUpdateBranch?: boolean;
requireCodeOwnerReviews?: boolean;
bypassPullRequestAllowances?: {
users?: string[];
teams?: string[];
apps?: string[];
};
requiredApprovingReviewCount?: number;
restrictions?: {
users: string[];
teams: string[];
apps?: string[];
};
requiredStatusCheckContexts?: string[];
requireBranchesToBeUpToDate?: boolean;
requiredConversationResolution?: boolean;
repoVisibility?: 'private' | 'internal' | 'public';
collaborators?: Array<
| {
user: string;
access: string;
}
| {
team: string;
access: string;
}
| {
/** @deprecated This field is deprecated in favor of team */
username: string;
access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
}
>;
hasProjects?: boolean;
hasWiki?: boolean;
hasIssues?: boolean;
token?: string;
topics?: string[];
repoVariables?: { [key: string]: string };
secrets?: { [key: string]: string };
oidcCustomization?: {
useDefault: boolean;
includeClaimKeys?: string[];
};
requireCommitSigning?: boolean;
requiredLinearHistory?: boolean;
customProperties?: { [key: string]: string };
subscribe?: boolean;
}>({
return createTemplateAction({
id: 'github:repo:create',
description: 'Creates a GitHub repository.',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl'],
properties: {
repoUrl: inputProps.repoUrl,
description: inputProps.description,
homepage: inputProps.homepage,
access: inputProps.access,
requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,
bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,
requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,
restrictions: inputProps.restrictions,
requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,
requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,
requiredConversationResolution:
inputProps.requiredConversationResolution,
repoVisibility: inputProps.repoVisibility,
deleteBranchOnMerge: inputProps.deleteBranchOnMerge,
allowMergeCommit: inputProps.allowMergeCommit,
allowSquashMerge: inputProps.allowSquashMerge,
squashMergeCommitTitle: inputProps.squashMergeCommitTitle,
squashMergeCommitMessage: inputProps.squashMergeCommitMessage,
allowRebaseMerge: inputProps.allowRebaseMerge,
allowAutoMerge: inputProps.allowAutoMerge,
allowUpdateBranch: inputProps.allowUpdateBranch,
collaborators: inputProps.collaborators,
hasProjects: inputProps.hasProjects,
hasWiki: inputProps.hasWiki,
hasIssues: inputProps.hasIssues,
token: inputProps.token,
topics: inputProps.topics,
repoVariables: inputProps.repoVariables,
secrets: inputProps.secrets,
oidcCustomization: inputProps.oidcCustomization,
requiredCommitSigning: inputProps.requiredCommitSigning,
requiredLinearHistory: inputProps.requiredLinearHistory,
customProperties: inputProps.customProperties,
subscribe: inputProps.subscribe,
},
repoUrl: inputProps.repoUrl,
description: inputProps.description,
homepage: inputProps.homepage,
access: inputProps.access,
requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,
bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,
requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,
restrictions: inputProps.restrictions,
requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,
requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,
requiredConversationResolution:
inputProps.requiredConversationResolution,
repoVisibility: inputProps.repoVisibility,
deleteBranchOnMerge: inputProps.deleteBranchOnMerge,
allowMergeCommit: inputProps.allowMergeCommit,
allowSquashMerge: inputProps.allowSquashMerge,
squashMergeCommitTitle: inputProps.squashMergeCommitTitle,
squashMergeCommitMessage: inputProps.squashMergeCommitMessage,
allowRebaseMerge: inputProps.allowRebaseMerge,
allowAutoMerge: inputProps.allowAutoMerge,
allowUpdateBranch: inputProps.allowUpdateBranch,
collaborators: inputProps.collaborators,
hasProjects: inputProps.hasProjects,
hasWiki: inputProps.hasWiki,
hasIssues: inputProps.hasIssues,
token: inputProps.token,
topics: inputProps.topics,
repoVariables: inputProps.repoVariables,
secrets: inputProps.secrets,
oidcCustomization: inputProps.oidcCustomization,
requiredCommitSigning: inputProps.requiredCommitSigning,
requiredLinearHistory: inputProps.requiredLinearHistory,
customProperties: inputProps.customProperties,
subscribe: inputProps.subscribe,
},
output: {
type: 'object',
properties: {
remoteUrl: outputProps.remoteUrl,
repoContentsUrl: outputProps.repoContentsUrl,
},
remoteUrl: outputProps.remoteUrl,
repoContentsUrl: outputProps.repoContentsUrl,
},
},
async handler(ctx) {
@@ -79,7 +79,7 @@ describe('github:repo:push examples', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext();
@@ -78,7 +78,7 @@ describe('github:repo:push', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext({
input: {
@@ -44,80 +44,39 @@ export function createGithubRepoPushAction(options: {
}) {
const { integrations, config, githubCredentialsProvider } = options;
return createTemplateAction<{
repoUrl: string;
description?: string;
defaultBranch?: string;
protectDefaultBranch?: boolean;
protectEnforceAdmins?: boolean;
gitCommitMessage?: string;
gitAuthorName?: string;
gitAuthorEmail?: string;
requireCodeOwnerReviews?: boolean;
dismissStaleReviews?: boolean;
bypassPullRequestAllowances?:
| {
users?: string[];
teams?: string[];
apps?: string[];
}
| undefined;
requiredApprovingReviewCount?: number;
restrictions?:
| {
users: string[];
teams: string[];
apps?: string[];
}
| undefined;
requiredStatusCheckContexts?: string[];
requireBranchesToBeUpToDate?: boolean;
requiredConversationResolution?: boolean;
sourcePath?: string;
token?: string;
requiredCommitSigning?: boolean;
requiredLinearHistory?: boolean;
requireLastPushApproval?: boolean;
}>({
return createTemplateAction({
id: 'github:repo:push',
description:
'Initializes a git repository of contents in workspace and publishes it to GitHub.',
examples,
schema: {
input: {
type: 'object',
required: ['repoUrl'],
properties: {
repoUrl: inputProps.repoUrl,
requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,
dismissStaleReviews: inputProps.dismissStaleReviews,
requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,
bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,
requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,
restrictions: inputProps.restrictions,
requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,
requiredConversationResolution:
inputProps.requiredConversationResolution,
requireLastPushApproval: inputProps.requireLastPushApproval,
defaultBranch: inputProps.defaultBranch,
protectDefaultBranch: inputProps.protectDefaultBranch,
protectEnforceAdmins: inputProps.protectEnforceAdmins,
gitCommitMessage: inputProps.gitCommitMessage,
gitAuthorName: inputProps.gitAuthorName,
gitAuthorEmail: inputProps.gitAuthorEmail,
sourcePath: inputProps.sourcePath,
token: inputProps.token,
requiredCommitSigning: inputProps.requiredCommitSigning,
requiredLinearHistory: inputProps.requiredLinearHistory,
},
repoUrl: inputProps.repoUrl,
requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,
dismissStaleReviews: inputProps.dismissStaleReviews,
requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,
bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,
requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,
restrictions: inputProps.restrictions,
requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,
requiredConversationResolution:
inputProps.requiredConversationResolution,
requireLastPushApproval: inputProps.requireLastPushApproval,
defaultBranch: inputProps.defaultBranch,
protectDefaultBranch: inputProps.protectDefaultBranch,
protectEnforceAdmins: inputProps.protectEnforceAdmins,
gitCommitMessage: inputProps.gitCommitMessage,
gitAuthorName: inputProps.gitAuthorName,
gitAuthorEmail: inputProps.gitAuthorEmail,
sourcePath: inputProps.sourcePath,
token: inputProps.token,
requiredCommitSigning: inputProps.requiredCommitSigning,
requiredLinearHistory: inputProps.requiredLinearHistory,
},
output: {
type: 'object',
properties: {
remoteUrl: outputProps.remoteUrl,
repoContentsUrl: outputProps.repoContentsUrl,
commitHash: outputProps.commitHash,
},
remoteUrl: outputProps.remoteUrl,
repoContentsUrl: outputProps.repoContentsUrl,
commitHash: outputProps.commitHash,
},
},
async handler(ctx) {
@@ -53,7 +53,7 @@ describe('github:webhook examples', () => {
const defaultWebhookSecret = 'aafdfdivierernfdk23f';
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
const mockContext = createMockActionContext();
@@ -51,7 +51,7 @@ describe('github:repository:webhook:create', () => {
const integrations = ScmIntegrations.fromConfig(config);
let githubCredentialsProvider: GithubCredentialsProvider;
const defaultWebhookSecret = 'aafdfdivierernfdk23f';
let action: TemplateAction<any>;
let action: TemplateAction<any, any, any>;
beforeEach(() => {
jest.resetAllMocks();
@@ -42,92 +42,74 @@ export function createGithubWebhookAction(options: {
const eventNames = emitterEventNames.filter(event => !event.includes('.'));
return createTemplateAction<{
repoUrl: string;
webhookUrl: string;
webhookSecret?: string;
events?: string[];
active?: boolean;
contentType?: 'form' | 'json';
insecureSsl?: boolean;
token?: string;
}>({
return createTemplateAction({
id: 'github:webhook',
description: 'Creates webhook for a repository on GitHub.',
examples,
supportsDryRun: true,
schema: {
input: {
type: 'object',
required: ['repoUrl', 'webhookUrl'],
properties: {
repoUrl: {
title: 'Repository Location',
repoUrl: z =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',
type: 'string',
},
webhookUrl: {
title: 'Webhook URL',
}),
webhookUrl: z =>
z.string({
description: 'The URL to which the payloads will be delivered',
type: 'string',
},
webhookSecret: {
title: 'Webhook Secret',
description:
'Webhook secret value. The default can be provided internally in action creation',
type: 'string',
},
events: {
title: 'Triggering Events',
description:
'Determines what events the hook is triggered for. Default: `[push]`',
type: 'array',
default: ['push'],
oneOf: [
{
items: {
type: 'string',
enum: eventNames,
},
},
{
items: {
type: 'string',
const: '*',
},
},
],
},
active: {
title: 'Active',
type: 'boolean',
default: true,
description:
'Determines if notifications are sent when the webhook is triggered. Default: `true`',
},
contentType: {
title: 'Content Type',
type: 'string',
enum: ['form', 'json'],
default: 'form',
description:
'The media type used to serialize the payloads. The default is `form`',
},
insecureSsl: {
title: 'Insecure SSL',
type: 'boolean',
default: false,
description:
'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',
},
token: {
title: 'Authentication Token',
type: 'string',
description:
'The `GITHUB_TOKEN` to use for authorization to GitHub',
},
},
}),
webhookSecret: z =>
z
.string({
description:
'Webhook secret value. The default can be provided internally in action creation',
})
.optional(),
events: z =>
z
.union([
z.array(z.enum(eventNames as [string, ...string[]]), {
description:
'Determines what events the hook is triggered for. Default: `[push]`',
}),
z.array(z.literal('*'), {
description:
'Determines what events the hook is triggered for. Use "*" for all events. Default: `[push]`',
}),
])
.default(['push'])
.optional(),
active: z =>
z
.boolean({
description:
'Determines if notifications are sent when the webhook is triggered. Default: `true`',
})
.default(true)
.optional(),
contentType: z =>
z
.enum(['form', 'json'], {
description:
'The media type used to serialize the payloads. The default is `form`',
})
.default('form')
.optional(),
insecureSsl: z =>
z
.boolean({
description:
'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',
})
.default(false)
.optional(),
token: z =>
z
.string({
description:
'The `GITHUB_TOKEN` to use for authorization to GitHub',
})
.optional(),
},
},
async handler(ctx) {
@@ -14,394 +14,438 @@
* limitations under the License.
*/
const repoUrl = {
title: 'Repository Location',
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',
type: 'string',
};
const description = {
title: 'Repository Description',
type: 'string',
};
const homepage = {
title: 'Repository Homepage',
type: 'string',
};
const access = {
title: 'Repository Access',
description:
'Sets an admin collaborator on the repository. Can either be a user reference different from `owner` in `repoUrl` or team reference, eg. `org/team-name`',
type: 'string',
};
const requireCodeOwnerReviews = {
title: 'Require CODEOWNER Reviews?',
description:
'Require an approved review in PR including files with a designated Code Owner',
type: 'boolean',
};
const dismissStaleReviews = {
title: 'Dismiss Stale Reviews',
description:
'New reviewable commits pushed to a matching branch will dismiss pull request review approvals.',
type: 'boolean',
};
const requiredStatusCheckContexts = {
title: 'Required Status Check Contexts',
description:
'The list of status checks to require in order to merge into this branch',
type: 'array',
items: {
type: 'string',
},
};
const requireBranchesToBeUpToDate = {
title: 'Require Branches To Be Up To Date?',
description:
'Require branches to be up to date before merging. The default value is `true`',
type: 'boolean',
default: true,
};
const requiredConversationResolution = {
title: 'Required Conversation Resolution',
description:
'Requires all conversations on code to be resolved before a pull request can be merged into this branch',
type: 'boolean',
};
const requireLastPushApproval = {
title: 'Require last push approval',
type: 'boolean',
default: false,
description:
'Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is `false`',
};
const repoVisibility = {
title: 'Repository Visibility',
type: 'string',
enum: ['private', 'public', 'internal'],
};
const deleteBranchOnMerge = {
title: 'Delete Branch On Merge',
type: 'boolean',
default: false,
description:
'Delete the branch after merging the PR. The default value is `false`',
};
const gitAuthorName = {
title: 'Default Author Name',
type: 'string',
default: 'Scaffolder',
description:
'Sets the default author name for the commit. The default value is `Scaffolder`',
};
const gitAuthorEmail = {
title: 'Default Author Email',
type: 'string',
description: `Sets the default author email for the commit.`,
};
const allowMergeCommit = {
title: 'Allow Merge Commits',
type: 'boolean',
default: true,
description: 'Allow merge commits. The default value is `true`',
};
const allowSquashMerge = {
title: 'Allow Squash Merges',
type: 'boolean',
default: true,
description: 'Allow squash merges. The default value is `true`',
};
const allowUpdateBranch = {
title: 'Allow Update Branch',
type: 'boolean',
default: false,
description: 'Allow branch to be updated. The default value is `false`',
};
const squashMergeCommitTitle = {
title: 'Default squash merge commit title',
enum: ['PR_TITLE', 'COMMIT_OR_PR_TITLE'],
type: 'string',
default: 'COMMIT_OR_PR_TITLE',
description:
'Sets the default value for a squash merge commit title. The default value is `COMMIT_OR_PR_TITLE`',
};
const squashMergeCommitMessage = {
title: 'Default squash merge commit message',
enum: ['PR_BODY', 'COMMIT_MESSAGES', 'BLANK'],
type: 'string',
default: 'COMMIT_MESSAGES',
description:
'Sets the default value for a squash merge commit message. The default value is `COMMIT_MESSAGES`',
};
const repoUrl = (z: typeof import('zod').z) =>
z.string({
description:
'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',
});
const allowRebaseMerge = {
title: 'Allow Rebase Merges',
type: 'boolean',
default: true,
description: 'Allow rebase merges. The default value is `true`',
};
const allowAutoMerge = {
title: 'Allow Auto Merges',
type: 'boolean',
default: false,
description:
'Allow individual PRs to merge automatically when all merge requirements are met. The default value is `false`',
};
const collaborators = {
title: 'Collaborators',
description: 'Provide additional users or teams with permissions',
type: 'array',
items: {
type: 'object',
additionalProperties: false,
required: ['access'],
properties: {
access: {
type: 'string',
description: 'The type of access for the user',
const description = (z: typeof import('zod').z) =>
z
.string({
description: 'Repository Description',
})
.optional();
const homepage = (z: typeof import('zod').z) =>
z
.string({
description: 'Repository Homepage',
})
.optional();
const access = (z: typeof import('zod').z) =>
z
.string({
description:
'Sets an admin collaborator on the repository. Can either be a user reference different from `owner` in `repoUrl` or team reference, eg. `org/team-name`',
})
.optional();
const requireCodeOwnerReviews = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Require an approved review in PR including files with a designated Code Owner',
})
.optional();
const dismissStaleReviews = (z: typeof import('zod').z) =>
z
.boolean({
description:
'New reviewable commits pushed to a matching branch will dismiss pull request review approvals.',
})
.optional();
const requiredStatusCheckContexts = (z: typeof import('zod').z) =>
z
.array(z.string(), {
description:
'The list of status checks to require in order to merge into this branch',
})
.optional();
const requireBranchesToBeUpToDate = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Require branches to be up to date before merging. The default value is `true`',
})
.default(true)
.optional();
const requiredConversationResolution = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Requires all conversations on code to be resolved before a pull request can be merged into this branch',
})
.optional();
const requireLastPushApproval = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is `false`',
})
.default(false)
.optional();
const repoVisibility = (z: typeof import('zod').z) =>
z
.enum(['private', 'public', 'internal'], {
description: 'Repository Visibility',
})
.optional();
const deleteBranchOnMerge = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Delete the branch after merging the PR. The default value is `false`',
})
.default(false)
.optional();
const gitAuthorName = (z: typeof import('zod').z) =>
z
.string({
description:
'Sets the default author name for the commit. The default value is `Scaffolder`',
})
.default('Scaffolder')
.optional();
const gitAuthorEmail = (z: typeof import('zod').z) =>
z
.string({
description: `Sets the default author email for the commit.`,
})
.optional();
const allowMergeCommit = (z: typeof import('zod').z) =>
z
.boolean({
description: 'Allow merge commits. The default value is `true`',
})
.default(true)
.optional();
const allowSquashMerge = (z: typeof import('zod').z) =>
z
.boolean({
description: 'Allow squash merges. The default value is `true`',
})
.default(true)
.optional();
const allowUpdateBranch = (z: typeof import('zod').z) =>
z
.boolean({
description: 'Allow branch to be updated. The default value is `false`',
})
.default(false)
.optional();
const squashMergeCommitTitle = (z: typeof import('zod').z) =>
z
.enum(['PR_TITLE', 'COMMIT_OR_PR_TITLE'], {
description:
'Sets the default value for a squash merge commit title. The default value is `COMMIT_OR_PR_TITLE`',
})
.default('COMMIT_OR_PR_TITLE')
.optional();
const squashMergeCommitMessage = (z: typeof import('zod').z) =>
z
.enum(['PR_BODY', 'COMMIT_MESSAGES', 'BLANK'], {
description:
'Sets the default value for a squash merge commit message. The default value is `COMMIT_MESSAGES`',
})
.default('COMMIT_MESSAGES')
.optional();
const allowRebaseMerge = (z: typeof import('zod').z) =>
z
.boolean({
description: 'Allow rebase merges. The default value is `true`',
})
.default(true)
.optional();
const allowAutoMerge = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Allow individual PRs to merge automatically when all merge requirements are met. The default value is `false`',
})
.default(false)
.optional();
const collaborators = (z: typeof import('zod').z) =>
z
.array(
z.union([
z.object({
access: z.string({
description: 'The type of access for the user',
}),
user: z.string({
description:
'The name of the user that will be added as a collaborator',
}),
}),
z.object({
access: z.string({
description: 'The type of access for the team',
}),
team: z.string({
description:
'The name of the team that will be added as a collaborator',
}),
}),
]),
{
description: 'Provide additional users or teams with permissions',
},
user: {
type: 'string',
)
.optional();
const hasProjects = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Enable projects for the repository. The default value is `true` unless the organization has disabled repository projects',
})
.optional();
const hasWiki = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Enable the wiki for the repository. The default value is `true`',
})
.default(true)
.optional();
const hasIssues = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Enable issues for the repository. The default value is `true`',
})
.default(true)
.optional();
const token = (z: typeof import('zod').z) =>
z
.string({
description: 'The token to use for authorization to GitHub',
})
.optional();
const topics = (z: typeof import('zod').z) =>
z
.array(z.string(), {
description: 'Adds topics to the repository',
})
.optional();
const defaultBranch = (z: typeof import('zod').z) =>
z
.string({
description: `Sets the default branch on the repository. The default value is 'master'`,
})
.default('master')
.optional();
const protectDefaultBranch = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Protect the default branch after creating the repository. The default value is `true`',
})
.default(true)
.optional();
const protectEnforceAdmins = (z: typeof import('zod').z) =>
z
.boolean({
description:
'Enforce admins to adhere to default branch protection. The default value is `true`',
})
.default(true)
.optional();
const bypassPullRequestAllowances = (z: typeof import('zod').z) =>
z
.object(
{
apps: z.array(z.string()).optional(),
users: z.array(z.string()).optional(),
teams: z.array(z.string()).optional(),
},
{
description:
'The name of the user that will be added as a collaborator',
'Allow specific users, teams, or apps to bypass pull request requirements.',
},
team: {
type: 'string',
)
.optional();
const gitCommitMessage = (z: typeof import('zod').z) =>
z
.string({
description:
'Sets the commit message on the repository. The default value is `initial commit`',
})
.default('initial commit')
.optional();
const sourcePath = (z: typeof import('zod').z) =>
z
.string({
description:
'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',
})
.optional();
const requiredApprovingReviewCount = (z: typeof import('zod').z) =>
z
.number({
description:
'Specify the number of reviewers required to approve pull requests. Use a number between `1` and `6` or `0` to not require reviewers. Defaults to `1`.',
})
.optional();
const restrictions = (z: typeof import('zod').z) =>
z
.object(
{
apps: z.array(z.string()).optional(),
users: z.array(z.string()),
teams: z.array(z.string()),
},
{
description:
'The name of the team that will be added as a collaborator',
'Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories.',
},
},
oneOf: [{ required: ['user'] }, { required: ['team'] }],
},
};
const hasProjects = {
title: 'Enable projects',
type: 'boolean',
description:
'Enable projects for the repository. The default value is `true` unless the organization has disabled repository projects',
};
const hasWiki = {
title: 'Enable the wiki',
type: 'boolean',
default: true,
description:
'Enable the wiki for the repository. The default value is `true`',
};
const hasIssues = {
title: 'Enable issues',
type: 'boolean',
default: true,
description: 'Enable issues for the repository. The default value is `true`',
};
const token = {
title: 'Authentication Token',
type: 'string',
description: 'The token to use for authorization to GitHub',
};
const topics = {
title: 'Topics',
type: 'array',
items: {
type: 'string',
},
};
const defaultBranch = {
title: 'Default Branch',
type: 'string',
default: 'master',
description:
'Sets the default branch on the repository. The default value is `master`',
};
const protectDefaultBranch = {
title: 'Protect Default Branch',
type: 'boolean',
default: true,
description:
'Protect the default branch after creating the repository. The default value is `true`',
};
const protectEnforceAdmins = {
title: 'Enforce Admins On Protected Branches',
type: 'boolean',
default: true,
description:
'Enforce admins to adhere to default branch protection. The default value is `true`',
};
)
.optional();
const bypassPullRequestAllowances = {
title: 'Bypass pull request requirements',
description:
'Allow specific users, teams, or apps to bypass pull request requirements.',
type: 'object',
additionalProperties: false,
properties: {
apps: {
type: 'array',
items: {
type: 'string',
const requiredCommitSigning = (z: typeof import('zod').z) =>
z
.boolean({
description: `Require commit signing so that you must sign commits on this branch.`,
})
.optional();
const requiredLinearHistory = (z: typeof import('zod').z) =>
z
.boolean({
description: `Prevent merge commits from being pushed to matching branches.`,
})
.optional();
const repoVariables = (z: typeof import('zod').z) =>
z
.record(z.string(), {
description: 'Variables attached to the repository',
})
.optional();
const secrets = (z: typeof import('zod').z) =>
z
.record(z.string(), {
description: 'Secrets attached to the repository',
})
.optional();
const oidcCustomization = (z: typeof import('zod').z) =>
z
.object(
{
useDefault: z
.boolean({
description: `Whether to use the default template or not. If true, includeClaimKeys must not be set.`,
})
.default(true),
includeClaimKeys: z
.array(z.string(), {
description: `Array of unique strings. Each claim key can only contain alphanumeric characters and underscores.`,
})
.optional(),
},
},
users: {
type: 'array',
items: {
type: 'string',
{
description: `OIDC customization template attached to the repository.`,
},
},
teams: {
type: 'array',
items: {
type: 'string',
},
},
},
};
)
.optional();
const gitCommitMessage = {
title: 'Git Commit Message',
type: 'string',
default: 'initial commit',
description:
'Sets the commit message on the repository. The default value is `initial commit`',
};
const sourcePath = {
title: 'Source Path',
description:
'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',
type: 'string',
};
const customProperties = (z: typeof import('zod').z) =>
z
.record(z.string(), {
description:
'Custom properties to be added to the repository (note, this only works for organization repositories)',
})
.optional();
const requiredApprovingReviewCount = {
title: 'Required approving review count',
type: 'number',
description:
'Specify the number of reviewers required to approve pull requests. Use a number between `1` and `6` or `0` to not require reviewers. Defaults to `1`.',
};
const subscribe = (z: typeof import('zod').z) =>
z
.boolean({
description: `Subscribe to the repository. The default value is 'false'`,
})
.optional();
const restrictions = {
title: 'Restrict who can push to the protected branch',
description:
'Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories.',
type: 'object',
additionalProperties: false,
properties: {
apps: {
type: 'array',
items: {
type: 'string',
},
},
users: {
type: 'array',
items: {
type: 'string',
},
},
teams: {
type: 'array',
items: {
type: 'string',
},
},
},
};
const branch = (z: typeof import('zod').z) =>
z
.string({
description: `The branch to protect. Defaults to the repository's default branch`,
})
.optional();
const requiredCommitSigning = {
title: 'Require commit signing',
type: 'boolean',
description: `Require commit signing so that you must sign commits on this branch.`,
export {
repoUrl,
description,
homepage,
access,
requireCodeOwnerReviews,
dismissStaleReviews,
requiredStatusCheckContexts,
requireBranchesToBeUpToDate,
requiredConversationResolution,
requireLastPushApproval,
repoVisibility,
deleteBranchOnMerge,
gitAuthorName,
gitAuthorEmail,
allowMergeCommit,
allowSquashMerge,
allowUpdateBranch,
squashMergeCommitTitle,
squashMergeCommitMessage,
allowRebaseMerge,
allowAutoMerge,
collaborators,
hasProjects,
hasWiki,
hasIssues,
token,
topics,
defaultBranch,
gitCommitMessage,
sourcePath,
repoVariables,
secrets,
oidcCustomization,
customProperties,
subscribe,
requiredApprovingReviewCount,
restrictions,
requiredCommitSigning,
requiredLinearHistory,
protectDefaultBranch,
protectEnforceAdmins,
bypassPullRequestAllowances,
branch,
};
const requiredLinearHistory = {
title: 'Require linear history',
type: 'boolean',
description: `Prevent merge commits from being pushed to matching branches.`,
};
const repoVariables = {
title: 'Repository Variables',
description: `Variables attached to the repository`,
type: 'object',
};
const secrets = {
title: 'Repository Secrets',
description: `Secrets attached to the repository`,
type: 'object',
};
const oidcCustomization = {
title: 'Repository OIDC customization template',
description: `OIDC customization template attached to the repository.`,
type: 'object',
additionalProperties: false,
properties: {
useDefault: {
title: 'Use Default',
type: 'boolean',
description: `Whether to use the default OIDC template or not.`,
},
includeClaimKeys: {
title: 'Include claim keys',
type: 'array',
items: {
type: 'string',
},
description: `Array of unique strings. Each claim key can only contain alphanumeric characters and underscores.`,
},
},
};
const customProperties = {
title: 'Custom Repository Properties',
description:
'Custom properties to be added to the repository (note, this only works for organization repositories)',
type: 'object',
};
const subscribe = {
title: 'Subscribe to repository',
description: `Subscribe to the repository. The default value is 'false'`,
type: 'boolean',
};
export { access };
export { allowMergeCommit };
export { allowRebaseMerge };
export { allowSquashMerge };
export { squashMergeCommitTitle };
export { squashMergeCommitMessage };
export { allowAutoMerge };
export { allowUpdateBranch };
export { collaborators };
export { defaultBranch };
export { deleteBranchOnMerge };
export { description };
export { gitAuthorEmail };
export { gitAuthorName };
export { gitCommitMessage };
export { homepage };
export { protectDefaultBranch };
export { protectEnforceAdmins };
export { bypassPullRequestAllowances };
export { requiredApprovingReviewCount };
export { restrictions };
export { repoUrl };
export { repoVisibility };
export { requireCodeOwnerReviews };
export { dismissStaleReviews };
export { requiredStatusCheckContexts };
export { requireBranchesToBeUpToDate };
export { requiredConversationResolution };
export { requireLastPushApproval };
export { hasProjects };
export { hasIssues };
export { hasWiki };
export { sourcePath };
export { token };
export { topics };
export { requiredCommitSigning };
export { requiredLinearHistory };
export { repoVariables };
export { secrets };
export { oidcCustomization };
export { customProperties };
export { subscribe };
@@ -14,19 +14,20 @@
* limitations under the License.
*/
const remoteUrl = {
title: 'A URL to the repository with the provider',
type: 'string',
};
const repoContentsUrl = {
title: 'A URL to the root of the repository',
type: 'string',
};
const remoteUrl = (z: typeof import('zod').z) =>
z.string({
description: 'A URL to the repository with the provider',
});
const commitHash = {
title: 'The git commit hash of the initial commit',
type: 'string',
};
const repoContentsUrl = (z: typeof import('zod').z) =>
z.string({
description: 'A URL to the root of the repository',
});
const commitHash = (z: typeof import('zod').z) =>
z.string({
description: 'The git commit hash of the initial commit',
});
export { remoteUrl };
export { repoContentsUrl };