@backstage/plugin-scaffolder-backend-module-github 0.9.8-next.1 → 0.9.8-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-github
2
2
 
3
+ ## 0.9.8-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 482ceed: Migrated from `assertError` to `toError` for error handling.
8
+ - Updated dependencies
9
+ - @backstage/errors@1.3.0-next.0
10
+ - @backstage/plugin-catalog-node@2.2.0-next.2
11
+ - @backstage/plugin-scaffolder-node@0.13.2-next.2
12
+ - @backstage/integration@2.0.1-next.0
13
+ - @backstage/backend-plugin-api@1.9.0-next.2
14
+ - @backstage/catalog-model@1.7.8-next.0
15
+ - @backstage/config@1.3.7-next.0
16
+
3
17
  ## 0.9.8-next.1
4
18
 
5
19
  ### Patch Changes
@@ -63,15 +63,15 @@ const enableBranchProtectionOnDefaultRepoBranch = async ({
63
63
  });
64
64
  }
65
65
  } catch (e) {
66
- errors.assertError(e);
67
- if (e.message.includes(
66
+ const error = errors.toError(e);
67
+ if (error.message.includes(
68
68
  "Upgrade to GitHub Pro or make this repository public to enable this feature"
69
69
  )) {
70
70
  logger.warn(
71
71
  "Branch protection was not enabled as it requires GitHub Pro for private repositories"
72
72
  );
73
73
  } else {
74
- throw e;
74
+ throw error;
75
75
  }
76
76
  }
77
77
  };
@@ -1 +1 @@
1
- {"version":3,"file":"gitHelpers.cjs.js","sources":["../../src/actions/gitHelpers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assertError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\ntype BranchProtectionOptions = {\n client: Octokit;\n owner: string;\n repoName: string;\n logger: LoggerService;\n requireCodeOwnerReviews: boolean;\n requiredStatusCheckContexts?: string[];\n bypassPullRequestAllowances?: {\n users?: string[];\n teams?: string[];\n apps?: string[];\n };\n requiredApprovingReviewCount?: number;\n restrictions?: {\n users: string[];\n teams: string[];\n apps?: string[];\n };\n requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n requireLastPushApproval: boolean;\n defaultBranch?: string;\n enforceAdmins?: boolean;\n dismissStaleReviews?: boolean;\n requiredCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n blockCreations?: boolean;\n};\n\nexport const enableBranchProtectionOnDefaultRepoBranch = async ({\n repoName,\n client,\n owner,\n logger,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n defaultBranch = 'master',\n enforceAdmins = true,\n dismissStaleReviews = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n blockCreations = false,\n}: BranchProtectionOptions): Promise<void> => {\n const tryOnce = async () => {\n try {\n await client.rest.repos.updateBranchProtection({\n mediaType: {\n /**\n * 👇 we need this preview because allowing a custom\n * reviewer count on branch protection is a preview\n * feature\n *\n * More here: https://docs.github.com/en/rest/overview/api-previews#require-multiple-approving-reviews\n */\n previews: ['luke-cage-preview'],\n },\n owner,\n repo: repoName,\n branch: defaultBranch,\n required_status_checks: {\n strict: requireBranchesToBeUpToDate,\n contexts: requiredStatusCheckContexts,\n },\n restrictions: restrictions ?? null,\n enforce_admins: enforceAdmins,\n required_pull_request_reviews: {\n required_approving_review_count: requiredApprovingReviewCount,\n require_code_owner_reviews: requireCodeOwnerReviews,\n bypass_pull_request_allowances: bypassPullRequestAllowances,\n dismiss_stale_reviews: dismissStaleReviews,\n require_last_push_approval: requireLastPushApproval,\n },\n required_conversation_resolution: requiredConversationResolution,\n required_linear_history: requiredLinearHistory,\n block_creations: blockCreations,\n });\n\n if (requiredCommitSigning) {\n await client.rest.repos.createCommitSignatureProtection({\n owner,\n repo: repoName,\n branch: defaultBranch,\n });\n }\n } catch (e) {\n assertError(e);\n if (\n e.message.includes(\n 'Upgrade to GitHub Pro or make this repository public to enable this feature',\n )\n ) {\n logger.warn(\n 'Branch protection was not enabled as it requires GitHub Pro for private repositories',\n );\n } else {\n throw e;\n }\n }\n };\n\n try {\n await tryOnce();\n } catch (e) {\n if (!e.message.includes('Branch not found')) {\n throw e;\n }\n\n // GitHub has eventual consistency. Fail silently, wait, and try again.\n await new Promise(resolve => setTimeout(resolve, 600));\n await tryOnce();\n }\n};\n\nexport function entityRefToName(name: string): string {\n return name.replace(/^.*[:/]/g, '');\n}\n"],"names":["assertError"],"mappings":";;;;AAiDO,MAAM,4CAA4C,OAAO;AAAA,EAC9D,QAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,uBAAA;AAAA,EACA,2BAAA;AAAA,EACA,4BAAA;AAAA,EACA,YAAA;AAAA,EACA,8BAA8B,EAAC;AAAA,EAC/B,2BAAA,GAA8B,IAAA;AAAA,EAC9B,8BAAA,GAAiC,KAAA;AAAA,EACjC,uBAAA,GAA0B,KAAA;AAAA,EAC1B,aAAA,GAAgB,QAAA;AAAA,EAChB,aAAA,GAAgB,IAAA;AAAA,EAChB,mBAAA,GAAsB,KAAA;AAAA,EACtB,qBAAA,GAAwB,KAAA;AAAA,EACxB,qBAAA,GAAwB,KAAA;AAAA,EACxB,cAAA,GAAiB;AACnB,CAAA,KAA8C;AAC5C,EAAA,MAAM,UAAU,YAAY;AAC1B,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,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,SAAS,CAAA,EAAG;AACV,IAAA,IAAI,CAAC,CAAA,CAAE,OAAA,CAAQ,QAAA,CAAS,kBAAkB,CAAA,EAAG;AAC3C,MAAA,MAAM,CAAA;AAAA,IACR;AAGA,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,OAAA,KAAW,UAAA,CAAW,OAAA,EAAS,GAAG,CAAC,CAAA;AACrD,IAAA,MAAM,OAAA,EAAQ;AAAA,EAChB;AACF;AAEO,SAAS,gBAAgB,IAAA,EAAsB;AACpD,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA;AACpC;;;;;"}
1
+ {"version":3,"file":"gitHelpers.cjs.js","sources":["../../src/actions/gitHelpers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { toError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\ntype BranchProtectionOptions = {\n client: Octokit;\n owner: string;\n repoName: string;\n logger: LoggerService;\n requireCodeOwnerReviews: boolean;\n requiredStatusCheckContexts?: string[];\n bypassPullRequestAllowances?: {\n users?: string[];\n teams?: string[];\n apps?: string[];\n };\n requiredApprovingReviewCount?: number;\n restrictions?: {\n users: string[];\n teams: string[];\n apps?: string[];\n };\n requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n requireLastPushApproval: boolean;\n defaultBranch?: string;\n enforceAdmins?: boolean;\n dismissStaleReviews?: boolean;\n requiredCommitSigning?: boolean;\n requiredLinearHistory?: boolean;\n blockCreations?: boolean;\n};\n\nexport const enableBranchProtectionOnDefaultRepoBranch = async ({\n repoName,\n client,\n owner,\n logger,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n defaultBranch = 'master',\n enforceAdmins = true,\n dismissStaleReviews = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n blockCreations = false,\n}: BranchProtectionOptions): Promise<void> => {\n const tryOnce = async () => {\n try {\n await client.rest.repos.updateBranchProtection({\n mediaType: {\n /**\n * 👇 we need this preview because allowing a custom\n * reviewer count on branch protection is a preview\n * feature\n *\n * More here: https://docs.github.com/en/rest/overview/api-previews#require-multiple-approving-reviews\n */\n previews: ['luke-cage-preview'],\n },\n owner,\n repo: repoName,\n branch: defaultBranch,\n required_status_checks: {\n strict: requireBranchesToBeUpToDate,\n contexts: requiredStatusCheckContexts,\n },\n restrictions: restrictions ?? null,\n enforce_admins: enforceAdmins,\n required_pull_request_reviews: {\n required_approving_review_count: requiredApprovingReviewCount,\n require_code_owner_reviews: requireCodeOwnerReviews,\n bypass_pull_request_allowances: bypassPullRequestAllowances,\n dismiss_stale_reviews: dismissStaleReviews,\n require_last_push_approval: requireLastPushApproval,\n },\n required_conversation_resolution: requiredConversationResolution,\n required_linear_history: requiredLinearHistory,\n block_creations: blockCreations,\n });\n\n if (requiredCommitSigning) {\n await client.rest.repos.createCommitSignatureProtection({\n owner,\n repo: repoName,\n branch: defaultBranch,\n });\n }\n } catch (e) {\n const error = toError(e);\n if (\n error.message.includes(\n 'Upgrade to GitHub Pro or make this repository public to enable this feature',\n )\n ) {\n logger.warn(\n 'Branch protection was not enabled as it requires GitHub Pro for private repositories',\n );\n } else {\n throw error;\n }\n }\n };\n\n try {\n await tryOnce();\n } catch (e) {\n if (!e.message.includes('Branch not found')) {\n throw e;\n }\n\n // GitHub has eventual consistency. Fail silently, wait, and try again.\n await new Promise(resolve => setTimeout(resolve, 600));\n await tryOnce();\n }\n};\n\nexport function entityRefToName(name: string): string {\n return name.replace(/^.*[:/]/g, '');\n}\n"],"names":["toError"],"mappings":";;;;AAiDO,MAAM,4CAA4C,OAAO;AAAA,EAC9D,QAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,uBAAA;AAAA,EACA,2BAAA;AAAA,EACA,4BAAA;AAAA,EACA,YAAA;AAAA,EACA,8BAA8B,EAAC;AAAA,EAC/B,2BAAA,GAA8B,IAAA;AAAA,EAC9B,8BAAA,GAAiC,KAAA;AAAA,EACjC,uBAAA,GAA0B,KAAA;AAAA,EAC1B,aAAA,GAAgB,QAAA;AAAA,EAChB,aAAA,GAAgB,IAAA;AAAA,EAChB,mBAAA,GAAsB,KAAA;AAAA,EACtB,qBAAA,GAAwB,KAAA;AAAA,EACxB,qBAAA,GAAwB,KAAA;AAAA,EACxB,cAAA,GAAiB;AACnB,CAAA,KAA8C;AAC5C,EAAA,MAAM,UAAU,YAAY;AAC1B,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,sBAAA,CAAuB;AAAA,QAC7C,SAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAQT,QAAA,EAAU,CAAC,mBAAmB;AAAA,SAChC;AAAA,QACA,KAAA;AAAA,QACA,IAAA,EAAM,QAAA;AAAA,QACN,MAAA,EAAQ,aAAA;AAAA,QACR,sBAAA,EAAwB;AAAA,UACtB,MAAA,EAAQ,2BAAA;AAAA,UACR,QAAA,EAAU;AAAA,SACZ;AAAA,QACA,cAAc,YAAA,IAAgB,IAAA;AAAA,QAC9B,cAAA,EAAgB,aAAA;AAAA,QAChB,6BAAA,EAA+B;AAAA,UAC7B,+BAAA,EAAiC,4BAAA;AAAA,UACjC,0BAAA,EAA4B,uBAAA;AAAA,UAC5B,8BAAA,EAAgC,2BAAA;AAAA,UAChC,qBAAA,EAAuB,mBAAA;AAAA,UACvB,0BAAA,EAA4B;AAAA,SAC9B;AAAA,QACA,gCAAA,EAAkC,8BAAA;AAAA,QAClC,uBAAA,EAAyB,qBAAA;AAAA,QACzB,eAAA,EAAiB;AAAA,OAClB,CAAA;AAED,MAAA,IAAI,qBAAA,EAAuB;AACzB,QAAA,MAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,+BAAA,CAAgC;AAAA,UACtD,KAAA;AAAA,UACA,IAAA,EAAM,QAAA;AAAA,UACN,MAAA,EAAQ;AAAA,SACT,CAAA;AAAA,MACH;AAAA,IACF,SAAS,CAAA,EAAG;AACV,MAAA,MAAM,KAAA,GAAQA,eAAQ,CAAC,CAAA;AACvB,MAAA,IACE,MAAM,OAAA,CAAQ,QAAA;AAAA,QACZ;AAAA,OACF,EACA;AACA,QAAA,MAAA,CAAO,IAAA;AAAA,UACL;AAAA,SACF;AAAA,MACF,CAAA,MAAO;AACL,QAAA,MAAM,KAAA;AAAA,MACR;AAAA,IACF;AAAA,EACF,CAAA;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,EAAQ;AAAA,EAChB,SAAS,CAAA,EAAG;AACV,IAAA,IAAI,CAAC,CAAA,CAAE,OAAA,CAAQ,QAAA,CAAS,kBAAkB,CAAA,EAAG;AAC3C,MAAA,MAAM,CAAA;AAAA,IACR;AAGA,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,OAAA,KAAW,UAAA,CAAW,OAAA,EAAS,GAAG,CAAC,CAAA;AACrD,IAAA,MAAM,OAAA,EAAQ;AAAA,EAChB;AACF;AAEO,SAAS,gBAAgB,IAAA,EAAsB;AACpD,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA;AACpC;;;;;"}
@@ -105,11 +105,11 @@ function createGithubActionsDispatchAction(options) {
105
105
  }
106
106
  }
107
107
  } catch (e) {
108
- errors.assertError(e);
108
+ const error = errors.toError(e);
109
109
  ctx.logger.warn(
110
- `Failed: dispatching workflow '${workflowId}' on repo: '${repo}', ${e.message}`
110
+ `Failed: dispatching workflow '${workflowId}' on repo: '${repo}', ${error.message}`
111
111
  );
112
- throw e;
112
+ throw error;
113
113
  }
114
114
  }
115
115
  });
@@ -1 +1 @@
1
- {"version":3,"file":"githubActionsDispatch.cjs.js","sources":["../../src/actions/githubActionsDispatch.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assertError, InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubActionsDispatch.examples';\n\n/**\n * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.\n * @public\n */\nexport function createGithubActionsDispatchAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:actions:dispatch',\n description:\n 'Dispatches a GitHub Action workflow for a given branch or tag',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n }),\n workflowId: z =>\n z.string({\n description: 'The GitHub Action Workflow filename',\n }),\n branchOrTagName: z =>\n z.string({\n description:\n 'The git branch or tag name used to dispatch the workflow',\n }),\n workflowInputs: z =>\n z\n .record(z.string(), {\n description:\n 'Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 25.',\n })\n .optional(),\n returnWorkflowRunDetails: z =>\n z\n .boolean({\n description:\n 'If true, returns the workflow run ID and URLs as action outputs.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n output: {\n workflowRunId: z =>\n z.number({ description: 'The triggered workflow run ID' }).optional(),\n workflowRunUrl: z =>\n z.string({ description: 'API URL of the workflow run' }).optional(),\n workflowRunHtmlUrl: z =>\n z.string({ description: 'HTML URL of the workflow run' }).optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n workflowId,\n branchOrTagName,\n workflowInputs,\n returnWorkflowRunDetails,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(\n `Dispatching workflow ${workflowId} for repo ${repoUrl} on ${branchOrTagName}`,\n );\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n host,\n owner,\n repo,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n try {\n const runDetails = await ctx.checkpoint({\n key: `create.workflow.dispatch.${owner}.${repo}.${workflowId}`,\n fn: async () => {\n const dispatchParams = {\n owner,\n repo,\n workflow_id: workflowId,\n ref: branchOrTagName,\n inputs: workflowInputs,\n ...(returnWorkflowRunDetails ? { return_run_details: true } : {}),\n };\n const response = await client.rest.actions.createWorkflowDispatch(\n dispatchParams,\n );\n\n ctx.logger.info(`Workflow ${workflowId} dispatched successfully`);\n\n if (returnWorkflowRunDetails && response.data) {\n // GitHub's API returns 200 with run details when return_run_details is true.\n // @octokit/openapi-types still types this as OctokitResponse<never, 204> because\n // it hasn't picked up the updated GitHub OpenAPI spec yet.\n // See: https://github.blog/changelog/2026-02-19-workflow-dispatch-api-now-returns-run-ids/\n // This cast can be removed once @octokit/openapi-types includes the updated spec.\n // Note: only supported on GitHub.com and GitHub Enterprise Cloud, not GitHub Enterprise Server\n const data = response.data as unknown as {\n workflow_run_id: number;\n run_url: string;\n html_url: string;\n };\n\n return {\n workflowRunId: data.workflow_run_id,\n workflowRunUrl: data.run_url,\n workflowRunHtmlUrl: data.html_url,\n };\n }\n return null;\n },\n });\n\n if (runDetails) {\n ctx.output('workflowRunId', runDetails.workflowRunId);\n ctx.output('workflowRunUrl', runDetails.workflowRunUrl);\n ctx.output('workflowRunHtmlUrl', runDetails.workflowRunHtmlUrl);\n\n if (runDetails.workflowRunHtmlUrl) {\n ctx.logger.info(\n `Workflow run url: ${runDetails.workflowRunHtmlUrl}`,\n );\n }\n }\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: dispatching workflow '${workflowId}' on repo: '${repo}', ${e.message}`,\n );\n throw e;\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,kCAAkC,OAAA,EAG/C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EACE,+DAAA;AAAA,cACFC,uCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,eAAA,EAAiB,CAAA,CAAA,KACf,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA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IAAA;AAAA,UACT;AAAA,SACD,CAAA;AAED,QAAA,IAAI,UAAA,EAAY;AACd,UAAA,GAAA,CAAI,MAAA,CAAO,eAAA,EAAiB,UAAA,CAAW,aAAa,CAAA;AACpD,UAAA,GAAA,CAAI,MAAA,CAAO,gBAAA,EAAkB,UAAA,CAAW,cAAc,CAAA;AACtD,UAAA,GAAA,CAAI,MAAA,CAAO,oBAAA,EAAsB,UAAA,CAAW,kBAAkB,CAAA;AAE9D,UAAA,IAAI,WAAW,kBAAA,EAAoB;AACjC,YAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,cACT,CAAA,kBAAA,EAAqB,WAAW,kBAAkB,CAAA;AAAA,aACpD;AAAA,UACF;AAAA,QACF;AAAA,MACF,SAAS,CAAA,EAAG;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,iCAAiC,UAAU,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SAC/E;AACA,QAAA,MAAM,CAAA;AAAA,MACR;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubActionsDispatch.cjs.js","sources":["../../src/actions/githubActionsDispatch.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError, toError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubActionsDispatch.examples';\n\n/**\n * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.\n * @public\n */\nexport function createGithubActionsDispatchAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:actions:dispatch',\n description:\n 'Dispatches a GitHub Action workflow for a given branch or tag',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n }),\n workflowId: z =>\n z.string({\n description: 'The GitHub Action Workflow filename',\n }),\n branchOrTagName: z =>\n z.string({\n description:\n 'The git branch or tag name used to dispatch the workflow',\n }),\n workflowInputs: z =>\n z\n .record(z.string(), {\n description:\n 'Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 25.',\n })\n .optional(),\n returnWorkflowRunDetails: z =>\n z\n .boolean({\n description:\n 'If true, returns the workflow run ID and URLs as action outputs.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n output: {\n workflowRunId: z =>\n z.number({ description: 'The triggered workflow run ID' }).optional(),\n workflowRunUrl: z =>\n z.string({ description: 'API URL of the workflow run' }).optional(),\n workflowRunHtmlUrl: z =>\n z.string({ description: 'HTML URL of the workflow run' }).optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n workflowId,\n branchOrTagName,\n workflowInputs,\n returnWorkflowRunDetails,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(\n `Dispatching workflow ${workflowId} for repo ${repoUrl} on ${branchOrTagName}`,\n );\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n host,\n owner,\n repo,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n try {\n const runDetails = await ctx.checkpoint({\n key: `create.workflow.dispatch.${owner}.${repo}.${workflowId}`,\n fn: async () => {\n const dispatchParams = {\n owner,\n repo,\n workflow_id: workflowId,\n ref: branchOrTagName,\n inputs: workflowInputs,\n ...(returnWorkflowRunDetails ? { return_run_details: true } : {}),\n };\n const response = await client.rest.actions.createWorkflowDispatch(\n dispatchParams,\n );\n\n ctx.logger.info(`Workflow ${workflowId} dispatched successfully`);\n\n if (returnWorkflowRunDetails && response.data) {\n // GitHub's API returns 200 with run details when return_run_details is true.\n // @octokit/openapi-types still types this as OctokitResponse<never, 204> because\n // it hasn't picked up the updated GitHub OpenAPI spec yet.\n // See: https://github.blog/changelog/2026-02-19-workflow-dispatch-api-now-returns-run-ids/\n // This cast can be removed once @octokit/openapi-types includes the updated spec.\n // Note: only supported on GitHub.com and GitHub Enterprise Cloud, not GitHub Enterprise Server\n const data = response.data as unknown as {\n workflow_run_id: number;\n run_url: string;\n html_url: string;\n };\n\n return {\n workflowRunId: data.workflow_run_id,\n workflowRunUrl: data.run_url,\n workflowRunHtmlUrl: data.html_url,\n };\n }\n return null;\n },\n });\n\n if (runDetails) {\n ctx.output('workflowRunId', runDetails.workflowRunId);\n ctx.output('workflowRunUrl', runDetails.workflowRunUrl);\n ctx.output('workflowRunHtmlUrl', runDetails.workflowRunHtmlUrl);\n\n if (runDetails.workflowRunHtmlUrl) {\n ctx.logger.info(\n `Workflow run url: ${runDetails.workflowRunHtmlUrl}`,\n );\n }\n }\n } catch (e) {\n const error = toError(e);\n ctx.logger.warn(\n `Failed: dispatching workflow '${workflowId}' on repo: '${repo}', ${error.message}`,\n );\n throw error;\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","toError"],"mappings":";;;;;;;;AAi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AA,MAAM,KAAA;AAAA,MACR;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -108,11 +108,11 @@ function createGithubIssuesCreateAction(options) {
108
108
  `Successfully created issue #${issue.number}: ${issue.html_url}`
109
109
  );
110
110
  } catch (e) {
111
- errors.assertError(e);
111
+ const error = errors.toError(e);
112
112
  ctx.logger.warn(
113
- `Failed: creating issue '${title}' on repo: '${repo}', ${e.message}`
113
+ `Failed: creating issue '${title}' on repo: '${repo}', ${error.message}`
114
114
  );
115
- throw e;
115
+ throw error;
116
116
  }
117
117
  }
118
118
  });
@@ -1 +1 @@
1
- {"version":3,"file":"githubIssuesCreate.cjs.js","sources":["../../src/actions/githubIssuesCreate.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesCreate.examples';\n\n/**\n * Creates an issue on GitHub\n * @public\n */\nexport function createGithubIssuesCreateAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:issues:create',\n description: 'Creates an issue on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n }),\n title: z =>\n z.string({\n description: 'The title of the issue',\n }),\n body: z =>\n z\n .string({\n description: 'The contents of the issue',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.string(), {\n description:\n 'Logins for Users to assign to this issue. NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise.',\n })\n .optional(),\n milestone: z =>\n z\n .union([z.string(), z.number()], {\n description:\n 'The number of the milestone to associate this issue with. NOTE: Only users with push access can set the milestone for new issues. The milestone is silently dropped otherwise.',\n })\n .optional(),\n labels: z =>\n z\n .array(z.string(), {\n description:\n 'Labels to associate with this issue. NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n output: {\n issueUrl: z =>\n z.string({\n description: 'The URL of the created issue',\n }),\n issueNumber: z =>\n z.number({\n description: 'The number of the created issue',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n title,\n body,\n assignees,\n milestone,\n labels,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Creating issue \"${title}\" on repo ${repo}`);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating issue \"${title}\"`);\n ctx.output('issueUrl', `https://github.com/${owner}/${repo}/issues/42`);\n ctx.output('issueNumber', 42);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const issue = await ctx.checkpoint({\n key: `github.issues.create.${owner}.${repo}.${title}`,\n fn: async () => {\n const response = await client.rest.issues.create({\n owner,\n repo,\n title,\n body,\n assignees,\n milestone,\n labels,\n });\n\n return {\n html_url: response.data.html_url,\n number: response.data.number,\n };\n },\n });\n\n if (!issue) {\n throw new Error('Failed to create issue');\n }\n\n ctx.output('issueUrl', issue.html_url);\n ctx.output('issueNumber', issue.number);\n\n ctx.logger.info(\n `Successfully created issue #${issue.number}: ${issue.html_url}`,\n );\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: creating issue '${title}' on repo: '${repo}', ${e.message}`,\n );\n throw e;\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,+BAA+B,OAAA,EAG5C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,sBAAA;AAAA,IACJ,WAAA,EAAa,6BAAA;AAAA,cACbC,oCAAA;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,IAAA,EAAM,CAAA,CAAA,KACJ,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,WAAW,CAAA,CAAA,KACT,CAAA,CACG,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UACjB,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CACG,KAAA,CAAM,CAAC,CAAA,CAA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,QAAA,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY,KAAA,CAAM,QAAQ,CAAA;AACrC,QAAA,GAAA,CAAI,MAAA,CAAO,aAAA,EAAe,KAAA,CAAM,MAAM,CAAA;AAEtC,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,CAAA,4BAAA,EAA+B,KAAA,CAAM,MAAM,CAAA,EAAA,EAAK,MAAM,QAAQ,CAAA;AAAA,SAChE;AAAA,MACF,SAAS,CAAA,EAAG;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,2BAA2B,KAAK,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SACpE;AACA,QAAA,MAAM,CAAA;AAAA,MACR;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubIssuesCreate.cjs.js","sources":["../../src/actions/githubIssuesCreate.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { InputError, toError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesCreate.examples';\n\n/**\n * Creates an issue on GitHub\n * @public\n */\nexport function createGithubIssuesCreateAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:issues:create',\n description: 'Creates an issue on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n }),\n title: z =>\n z.string({\n description: 'The title of the issue',\n }),\n body: z =>\n z\n .string({\n description: 'The contents of the issue',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.string(), {\n description:\n 'Logins for Users to assign to this issue. NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise.',\n })\n .optional(),\n milestone: z =>\n z\n .union([z.string(), z.number()], {\n description:\n 'The number of the milestone to associate this issue with. NOTE: Only users with push access can set the milestone for new issues. The milestone is silently dropped otherwise.',\n })\n .optional(),\n labels: z =>\n z\n .array(z.string(), {\n description:\n 'Labels to associate with this issue. NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n output: {\n issueUrl: z =>\n z.string({\n description: 'The URL of the created issue',\n }),\n issueNumber: z =>\n z.number({\n description: 'The number of the created issue',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n title,\n body,\n assignees,\n milestone,\n labels,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Creating issue \"${title}\" on repo ${repo}`);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating issue \"${title}\"`);\n ctx.output('issueUrl', `https://github.com/${owner}/${repo}/issues/42`);\n ctx.output('issueNumber', 42);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const issue = await ctx.checkpoint({\n key: `github.issues.create.${owner}.${repo}.${title}`,\n fn: async () => {\n const response = await client.rest.issues.create({\n owner,\n repo,\n title,\n body,\n assignees,\n milestone,\n labels,\n });\n\n return {\n html_url: response.data.html_url,\n number: response.data.number,\n };\n },\n });\n\n if (!issue) {\n throw new Error('Failed to create issue');\n }\n\n ctx.output('issueUrl', issue.html_url);\n ctx.output('issueNumber', issue.number);\n\n ctx.logger.info(\n `Successfully created issue #${issue.number}: ${issue.html_url}`,\n );\n } catch (e) {\n const error = toError(e);\n ctx.logger.warn(\n `Failed: creating issue '${title}' on repo: '${repo}', ${error.message}`,\n );\n throw error;\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","toError"],"mappings":";;;;;;;;AAiCO,SAAS,+BAA+B,OAAA,EAG5C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,sBAAA;AAAA,IACJ,WAAA,EAAa,6BAAA;AAAA,cACbC,oCAAA;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,IAAA,EAAM,CAAA,CAAA,KACJ,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,WAAW,CAAA,CAA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AA;AAAA,cACxB,MAAA,EAAQ,SAAS,IAAA,CAAK;AAAA,aACxB;AAAA,UACF;AAAA,SACD,CAAA;AAED,QAAA,IAAI,CAAC,KAAA,EAAO;AACV,UAAA,MAAM,IAAI,MAAM,wBAAwB,CAAA;AAAA,QAC1C;AAEA,QAAA,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY,KAAA,CAAM,QAAQ,CAAA;AACrC,QAAA,GAAA,CAAI,MAAA,CAAO,aAAA,EAAe,KAAA,CAAM,MAAM,CAAA;AAEtC,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,CAAA,4BAAA,EAA+B,KAAA,CAAM,MAAM,CAAA,EAAA,EAAK,MAAM,QAAQ,CAAA;AAAA,SAChE;AAAA,MACF,SAAS,CAAA,EAAG;AACV,QAAA,MAAM,KAAA,GAAQC,eAAQ,CAAC,CAAA;AACvB,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,2BAA2B,KAAK,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,MAAM,OAAO,CAAA;AAAA,SACxE;AACA,QAAA,MAAM,KAAA;AAAA,MACR;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -60,9 +60,8 @@ function createGithubIssuesLabelAction(options) {
60
60
  }
61
61
  });
62
62
  } catch (e) {
63
- errors.assertError(e);
64
63
  ctx.logger.warn(
65
- `Failed: adding labels to issue: '${number}' on repo: '${repo}', ${e.message}`
64
+ `Failed: adding labels to issue: '${number}' on repo: '${repo}', ${errors.toError(e).message}`
66
65
  );
67
66
  }
68
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"githubIssuesLabel.cjs.js","sources":["../../src/actions/githubIssuesLabel.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesLabel.examples';\n\n/**\n * Adds labels to a pull request or issue on GitHub\n * @public\n */\nexport function createGithubIssuesLabelAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:issues:label',\n description: 'Adds labels to a pull request or issue on GitHub.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n }),\n number: z =>\n z.number({\n description: 'The pull request or issue number to add labels to',\n }),\n labels: z =>\n z.array(z.string(), {\n description: 'The labels to add to the pull request or issue',\n }),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const { repoUrl, number, labels, token: providedToken } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n try {\n await ctx.checkpoint({\n key: `github.issues.add.label.${owner}.${repo}.${number}`,\n fn: async () => {\n await client.rest.issues.addLabels({\n owner,\n repo,\n issue_number: number,\n labels,\n });\n },\n });\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: adding labels to issue: '${number}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,8BAA8B,OAAA,EAG3C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,qBAAA;AAAA,IACJ,WAAA,EAAa,mDAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,QAAQ,CAAA,CAAA,KACN,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UAClB,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,MAAM,EAAE,OAAA,EAAS,MAAA,EAAQ,QAAQ,KAAA,EAAO,aAAA,KAAkB,GAAA,CAAI,KAAA;AAE9D,MAAA,MAAM,EAAE,IAAA,EAAM,KAAA,EAAO,MAAK,GAAIC,iCAAA,CAAa,SAAS,YAAY,CAAA;AAChE,MAAA,GAAA,CAAI,OAAO,IAAA,CAAK,CAAA,iBAAA,EAAoB,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,CAAE,CAAA;AAElE,MAAA,IAAI,CAAC,KAAA,EAAO;AACV,QAAA,MAAM,IAAIC,kBAAW,8CAA8C,CAAA;AAAA,MACrE;AAEA,MAAA,MAAM,cAAA,GAAiB,MAAMC,sBAAA,CAAkB;AAAA,QAC7C,YAAA;AAAA,QACA,mBAAA,EAAqB,yBAAA;AAAA,QACrB,IAAA;AAAA,QACA,KAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA,EAAO;AAAA,OACR,CAAA;AACD,MAAA,MAAM,MAAA,GAAS,IAAIC,eAAA,CAAQ;AAAA,QACzB,GAAG,cAAA;AAAA,QACH,KAAK,GAAA,CAAI;AAAA,OACV,CAAA;AAED,MAAA,IAAI;AACF,QAAA,MAAM,IAAI,UAAA,CAAW;AAAA,UACnB,KAAK,CAAA,wBAAA,EAA2B,KAAK,CAAA,CAAA,EAAI,IAAI,IAAI,MAAM,CAAA,CAAA;AAAA,UACvD,IAAI,YAAY;AACd,YAAA,MAAM,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU;AAAA,cACjC,KAAA;AAAA,cACA,IAAA;AAAA,cACA,YAAA,EAAc,MAAA;AAAA,cACd;AAAA,aACD,CAAA;AAAA,UACH;AAAA,SACD,CAAA;AAAA,MACH,SAAS,CAAA,EAAG;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,oCAAoC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SAC9E;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubIssuesLabel.cjs.js","sources":["../../src/actions/githubIssuesLabel.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { InputError, toError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesLabel.examples';\n\n/**\n * Adds labels to a pull request or issue on GitHub\n * @public\n */\nexport function createGithubIssuesLabelAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction({\n id: 'github:issues:label',\n description: 'Adds labels to a pull request or issue on GitHub.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n }),\n number: z =>\n z.number({\n description: 'The pull request or issue number to add labels to',\n }),\n labels: z =>\n z.array(z.string(), {\n description: 'The labels to add to the pull request or issue',\n }),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const { repoUrl, number, labels, token: providedToken } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n try {\n await ctx.checkpoint({\n key: `github.issues.add.label.${owner}.${repo}.${number}`,\n fn: async () => {\n await client.rest.issues.addLabels({\n owner,\n repo,\n issue_number: number,\n labels,\n });\n },\n });\n } catch (e) {\n ctx.logger.warn(\n `Failed: adding labels to issue: '${number}' on repo: '${repo}', ${\n toError(e).message\n }`,\n );\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","toError"],"mappings":";;;;;;;;AAiCO,SAAS,8BAA8B,OAAA,EAG3C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,qBAAA;AAAA,IACJ,WAAA,EAAa,mDAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,QAAQ,CAAA,CAAA,KACN,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UAClB,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,MAAM,EAAE,OAAA,EAAS,MAAA,EAAQ,QAAQ,KAAA,EAAO,aAAA,KAAkB,GAAA,CAAI,KAAA;AAE9D,MAAA,MAAM,EAAE,IAAA,EAAM,KAAA,EAAO,MAAK,GAAIC,iCAAA,CAAa,SAAS,YAAY,CAAA;AAChE,MAAA,GAAA,CAAI,OAAO,IAAA,CAAK,CAAA,iBAAA,EAAoB,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,CAAE,CAAA;AAElE,MAAA,IAAI,CAAC,KAAA,EAAO;AACV,QAAA,MAAM,IAAIC,kBAAW,8CAA8C,CAAA;AAAA,MACrE;AAEA,MAAA,MAAM,cAAA,GAAiB,MAAMC,sBAAA,CAAkB;AAAA,QAC7C,YAAA;AAAA,QACA,mBAAA,EAAqB,yBAAA;AAAA,QACrB,IAAA;AAAA,QACA,KAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA,EAAO;AAAA,OACR,CAAA;AACD,MAAA,MAAM,MAAA,GAAS,IAAIC,eAAA,CAAQ;AAAA,QACzB,GAAG,cAAA;AAAA,QACH,KAAK,GAAA,CAAI;AAAA,OACV,CAAA;AAED,MAAA,IAAI;AACF,QAAA,MAAM,IAAI,UAAA,CAAW;AAAA,UACnB,KAAK,CAAA,wBAAA,EAA2B,KAAK,CAAA,CAAA,EAAI,IAAI,IAAI,MAAM,CAAA,CAAA;AAAA,UACvD,IAAI,YAAY;AACd,YAAA,MAAM,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU;AAAA,cACjC,KAAA;AAAA,cACA,IAAA;AAAA,cACA,YAAA,EAAc,MAAA;AAAA,cACd;AAAA,aACD,CAAA;AAAA,UACH;AAAA,SACD,CAAA;AAAA,MACH,SAAS,CAAA,EAAG;AACV,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,CAAA,iCAAA,EAAoC,MAAM,CAAA,YAAA,EAAe,IAAI,MAC3DC,cAAA,CAAQ,CAAC,EAAE,OACb,CAAA;AAAA,SACF;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -101,9 +101,8 @@ function createGithubWebhookAction(options) {
101
101
  });
102
102
  ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);
103
103
  } catch (e) {
104
- errors.assertError(e);
105
104
  ctx.logger.warn(
106
- `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${e.message}`
105
+ `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${errors.toError(e).message}`
107
106
  );
108
107
  }
109
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"githubWebhook.cjs.js","sources":["../../src/actions/githubWebhook.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { emitterEventNames } from '@octokit/webhooks';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubWebhook.examples';\n\n/**\n * Creates new action that creates a webhook for a repository on GitHub.\n * @public\n */\nexport function createGithubWebhookAction(options: {\n integrations: ScmIntegrationRegistry;\n defaultWebhookSecret?: string;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, defaultWebhookSecret, githubCredentialsProvider } =\n options;\n\n const eventNames = emitterEventNames.filter(event => !event.includes('.'));\n\n return createTemplateAction({\n id: 'github:webhook',\n description: 'Creates webhook for a repository on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n }),\n webhookUrl: z =>\n z.string({\n description: 'The URL to which the payloads will be delivered',\n }),\n webhookSecret: z =>\n z\n .string({\n description:\n 'Webhook secret value. The default can be provided internally in action creation',\n })\n .optional(),\n events: z =>\n z\n .union([\n z.array(z.enum(eventNames as [string, ...string[]]), {\n description:\n 'Determines what events the hook is triggered for. Default: `[push]`',\n }),\n z.array(z.literal('*'), {\n description:\n 'Determines what events the hook is triggered for. Use \"*\" for all events. Default: `[push]`',\n }),\n ])\n .default(['push'])\n .optional(),\n active: z =>\n z\n .boolean({\n description:\n 'Determines if notifications are sent when the webhook is triggered. Default: `true`',\n })\n .default(true)\n .optional(),\n contentType: z =>\n z\n .enum(['form', 'json'], {\n description:\n 'The media type used to serialize the payloads. The default is `form`',\n })\n .default('form')\n .optional(),\n insecureSsl: z =>\n z\n .boolean({\n description:\n 'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',\n })\n .default(false)\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n webhookUrl,\n webhookSecret = defaultWebhookSecret,\n events = ['push'],\n active = true,\n contentType = 'form',\n insecureSsl = false,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const insecure_ssl = insecureSsl ? '1' : '0';\n\n await ctx.checkpoint({\n key: `create.webhhook.${owner}.${repo}.${webhookUrl}`,\n fn: async () => {\n await client.rest.repos.createWebhook({\n owner,\n repo,\n config: {\n url: webhookUrl,\n content_type: contentType,\n secret: webhookSecret,\n insecure_ssl,\n },\n events,\n active,\n });\n },\n });\n\n ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["emitterEventNames","createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","assertError"],"mappings":";;;;;;;;;AAkCO,SAAS,0BAA0B,OAAA,EAIvC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,oBAAA,EAAsB,yBAAA,EAA0B,GACpE,OAAA;AAEF,EAAA,MAAM,UAAA,GAAaA,2BAAkB,MAAA,CAAO,CAAA,KAAA,KAAS,CAAC,KAAA,CAAM,QAAA,CAAS,GAAG,CAAC,CAAA;AAEzE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EAAa,6CAAA;AAAA,cACbC,+BAAA;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,KAAA,CAAM;AAAA,UACL,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,IAAA,CAAK,UAAmC,CAAA,EAAG;AAAA,YACnD,WAAA,EACE;AAAA,WACH,CAAA;AA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;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,2BAA2B,UAAU,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SACzE;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubWebhook.cjs.js","sources":["../../src/actions/githubWebhook.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { emitterEventNames } from '@octokit/webhooks';\nimport { InputError, toError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubWebhook.examples';\n\n/**\n * Creates new action that creates a webhook for a repository on GitHub.\n * @public\n */\nexport function createGithubWebhookAction(options: {\n integrations: ScmIntegrationRegistry;\n defaultWebhookSecret?: string;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, defaultWebhookSecret, githubCredentialsProvider } =\n options;\n\n const eventNames = emitterEventNames.filter(event => !event.includes('.'));\n\n return createTemplateAction({\n id: 'github:webhook',\n description: 'Creates webhook for a repository on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username',\n }),\n webhookUrl: z =>\n z.string({\n description: 'The URL to which the payloads will be delivered',\n }),\n webhookSecret: z =>\n z\n .string({\n description:\n 'Webhook secret value. The default can be provided internally in action creation',\n })\n .optional(),\n events: z =>\n z\n .union([\n z.array(z.enum(eventNames as [string, ...string[]]), {\n description:\n 'Determines what events the hook is triggered for. Default: `[push]`',\n }),\n z.array(z.literal('*'), {\n description:\n 'Determines what events the hook is triggered for. Use \"*\" for all events. Default: `[push]`',\n }),\n ])\n .default(['push'])\n .optional(),\n active: z =>\n z\n .boolean({\n description:\n 'Determines if notifications are sent when the webhook is triggered. Default: `true`',\n })\n .default(true)\n .optional(),\n contentType: z =>\n z\n .enum(['form', 'json'], {\n description:\n 'The media type used to serialize the payloads. The default is `form`',\n })\n .default('form')\n .optional(),\n insecureSsl: z =>\n z\n .boolean({\n description:\n 'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',\n })\n .default(false)\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n webhookUrl,\n webhookSecret = defaultWebhookSecret,\n events = ['push'],\n active = true,\n contentType = 'form',\n insecureSsl = false,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const insecure_ssl = insecureSsl ? '1' : '0';\n\n await ctx.checkpoint({\n key: `create.webhhook.${owner}.${repo}.${webhookUrl}`,\n fn: async () => {\n await client.rest.repos.createWebhook({\n owner,\n repo,\n config: {\n url: webhookUrl,\n content_type: contentType,\n secret: webhookSecret,\n insecure_ssl,\n },\n events,\n active,\n });\n },\n });\n\n ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);\n } catch (e) {\n ctx.logger.warn(\n `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${\n toError(e).message\n }`,\n );\n }\n },\n });\n}\n"],"names":["emitterEventNames","createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","toError"],"mappings":";;;;;;;;;AAkCO,SAAS,0BAA0B,OAAA,EAIvC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,oBAAA,EAAsB,yBAAA,EAA0B,GACpE,OAAA;AAEF,EAAA,MAAM,UAAA,GAAaA,2BAAkB,MAAA,CAAO,CAAA,KAAA,KAAS,CAAC,KAAA,CAAM,QAAA,CAAS,GAAG,CAAC,CAAA;AAEzE,EAAA,OAAOC,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EAAa,6CAAA;AAAA,cACbC,+BAAA;AAAA,IACA,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,MAAA,EAAQ,CAAA,CAAA,KACN,CAAA,CACG,KAAA,CAAM;AAAA,UACL,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,IAAA,CAAK,UAAmC,CAAA,EAAG;A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AAwB,CAAA;AAAA,MAChE,SAAS,CAAA,EAAG;AACV,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,CAAA,wBAAA,EAA2B,UAAU,CAAA,YAAA,EAAe,IAAI,MACtDC,cAAA,CAAQ,CAAC,EAAE,OACb,CAAA;AAAA,SACF;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -46,14 +46,13 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
46
46
  try {
47
47
  newRepo = (await repoCreationPromise).data;
48
48
  } catch (e) {
49
- errors.assertError(e);
50
- if (e.message === "Resource not accessible by integration") {
49
+ if (errors.toError(e).message === "Resource not accessible by integration") {
51
50
  logger.warn(
52
51
  `The GitHub app or token provided may not have the required permissions to create the ${user.data.type} repository ${owner}/${repo}.`
53
52
  );
54
53
  }
55
54
  throw new Error(
56
- `Failed to create the ${user.data.type} repository ${owner}/${repo}, ${e.message}`
55
+ `Failed to create the ${user.data.type} repository ${owner}/${repo}, ${errors.toError(e).message}`
57
56
  );
58
57
  }
59
58
  if (access?.startsWith(`${owner}/`)) {
@@ -93,10 +92,9 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
93
92
  });
94
93
  }
95
94
  } catch (e) {
96
- errors.assertError(e);
97
95
  const name = extractCollaboratorName(collaborator);
98
96
  logger.warn(
99
- `Skipping ${collaborator.access} access for ${name}, ${e.message}`
97
+ `Skipping ${collaborator.access} access for ${name}, ${errors.toError(e).message}`
100
98
  );
101
99
  }
102
100
  }
@@ -109,8 +107,7 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
109
107
  names: topics.map((t) => t.toLowerCase())
110
108
  });
111
109
  } catch (e) {
112
- errors.assertError(e);
113
- logger.warn(`Skipping topics ${topics.join(" ")}, ${e.message}`);
110
+ logger.warn(`Skipping topics ${topics.join(" ")}, ${errors.toError(e).message}`);
114
111
  }
115
112
  }
116
113
  for (const [key, value] of Object.entries(repoVariables ?? {})) {
@@ -218,17 +215,20 @@ async function initRepoPushAndProtect(remoteUrl, password, workspacePath, source
218
215
  requiredLinearHistory
219
216
  });
220
217
  } catch (e) {
221
- errors.assertError(e);
222
218
  logger.warn(
223
- `Skipping: default branch protection on '${repo}', ${e.message}`
219
+ `Skipping: default branch protection on '${repo}', ${errors.toError(e).message}`
224
220
  );
225
221
  }
226
222
  }
227
223
  return { commitHash: commitResult.commitHash };
228
224
  }
229
225
  function extractCollaboratorName(collaborator) {
230
- if ("username" in collaborator) return collaborator.username;
231
- if ("user" in collaborator) return collaborator.user;
226
+ if ("username" in collaborator) {
227
+ return collaborator.username;
228
+ }
229
+ if ("user" in collaborator) {
230
+ return collaborator.user;
231
+ }
232
232
  return collaborator.team;
233
233
  }
234
234
  async function validateAccessTeam(client, access) {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { assertError, NotFoundError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\n\nimport {\n getRepoSourceDirectory,\n initRepoAndPush,\n} from '@backstage/plugin-scaffolder-node';\n\nimport Sodium from 'libsodium-wrappers';\nimport {\n enableBranchProtectionOnDefaultRepoBranch,\n entityRefToName,\n} from './gitHelpers';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nexport async function createGithubRepoWithCollaboratorsAndTopics(\n client: Octokit,\n repo: string,\n owner: string,\n repoVisibility: 'private' | 'internal' | 'public' | undefined,\n description: string | undefined,\n homepage: string | undefined,\n deleteBranchOnMerge: boolean,\n allowMergeCommit: boolean,\n allowSquashMerge: boolean,\n squashMergeCommitTitle: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE' | undefined,\n squashMergeCommitMessage: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK' | undefined,\n allowRebaseMerge: boolean,\n allowAutoMerge: boolean,\n allowUpdateBranch: boolean,\n access: string | undefined,\n collaborators:\n | (\n | {\n user: string;\n access: string;\n }\n | {\n team: string;\n access: string;\n }\n | {\n /** @deprecated This field is deprecated in favor of team */\n username: string;\n access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';\n }\n )[]\n | undefined,\n hasProjects: boolean | undefined,\n hasWiki: boolean | undefined,\n hasIssues: boolean | undefined,\n topics: string[] | undefined,\n repoVariables: { [key: string]: string } | undefined,\n secrets: { [key: string]: string } | undefined,\n oidcCustomization:\n | {\n useDefault: boolean;\n includeClaimKeys?: string[];\n }\n | undefined,\n customProperties: { [key: string]: string | string[] } | undefined,\n subscribe: boolean | undefined,\n logger: LoggerService,\n autoInit?: boolean | undefined,\n workflowAccess?: 'none' | 'organization' | 'user',\n) {\n const user = await client.rest.users.getByUsername({\n username: owner,\n });\n\n if (access?.startsWith(`${owner}/`)) {\n await validateAccessTeam(client, access);\n }\n\n const baseRepoParams = {\n allow_auto_merge: allowAutoMerge,\n allow_merge_commit: allowMergeCommit,\n allow_rebase_merge: allowRebaseMerge,\n allow_squash_merge: allowSquashMerge,\n allow_update_branch: allowUpdateBranch,\n auto_init: autoInit,\n delete_branch_on_merge: deleteBranchOnMerge,\n description,\n has_issues: hasIssues,\n has_projects: hasProjects,\n has_wiki: hasWiki,\n homepage,\n name: repo,\n private: repoVisibility === 'private',\n squash_merge_commit_message: squashMergeCommitMessage,\n squash_merge_commit_title: squashMergeCommitTitle,\n };\n const repoCreationPromise =\n user.data.type === 'Organization'\n ? client.rest.repos.createInOrg({\n ...baseRepoParams,\n // Custom properties only available on org repos\n custom_properties: customProperties,\n org: owner,\n // @ts-ignore https://github.com/octokit/types.ts/issues/522\n visibility: repoVisibility,\n })\n : client.rest.repos.createForAuthenticatedUser(baseRepoParams);\n\n let newRepo;\n\n try {\n newRepo = (await repoCreationPromise).data;\n } catch (e) {\n assertError(e);\n if (e.message === 'Resource not accessible by integration') {\n logger.warn(\n `The GitHub app or token provided may not have the required permissions to create the ${user.data.type} repository ${owner}/${repo}.`,\n );\n }\n throw new Error(\n `Failed to create the ${user.data.type} repository ${owner}/${repo}, ${e.message}`,\n );\n }\n\n if (access?.startsWith(`${owner}/`)) {\n const [, team] = access.split('/');\n await client.rest.teams.addOrUpdateRepoPermissionsInOrg({\n org: owner,\n team_slug: team,\n owner,\n repo,\n permission: 'admin',\n });\n // No need to add access if it's the person who owns the personal account\n } else if (access && access !== owner) {\n await client.rest.repos.addCollaborator({\n owner,\n repo,\n username: access,\n permission: 'admin',\n });\n }\n\n if (collaborators) {\n for (const collaborator of collaborators) {\n try {\n if ('user' in collaborator) {\n await client.rest.repos.addCollaborator({\n owner,\n repo,\n username: entityRefToName(collaborator.user),\n permission: collaborator.access,\n });\n } else if ('team' in collaborator) {\n await client.rest.teams.addOrUpdateRepoPermissionsInOrg({\n org: owner,\n team_slug: entityRefToName(collaborator.team),\n owner,\n repo,\n permission: collaborator.access,\n });\n }\n } catch (e) {\n assertError(e);\n const name = extractCollaboratorName(collaborator);\n logger.warn(\n `Skipping ${collaborator.access} access for ${name}, ${e.message}`,\n );\n }\n }\n }\n\n if (topics) {\n try {\n await client.rest.repos.replaceAllTopics({\n owner,\n repo,\n names: topics.map(t => t.toLowerCase()),\n });\n } catch (e) {\n assertError(e);\n logger.warn(`Skipping topics ${topics.join(' ')}, ${e.message}`);\n }\n }\n\n for (const [key, value] of Object.entries(repoVariables ?? {})) {\n await client.rest.actions.createRepoVariable({\n owner,\n repo,\n name: key,\n value: value,\n });\n }\n\n if (secrets) {\n const publicKeyResponse = await client.rest.actions.getRepoPublicKey({\n owner,\n repo,\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKeyResponse.data.key,\n Sodium.base64_variants.ORIGINAL,\n );\n for (const [key, value] of Object.entries(secrets)) {\n const binarySecret = Sodium.from_string(value);\n const encryptedBinarySecret = Sodium.crypto_box_seal(\n binarySecret,\n binaryKey,\n );\n const encryptedBase64Secret = Sodium.to_base64(\n encryptedBinarySecret,\n Sodium.base64_variants.ORIGINAL,\n );\n\n await client.rest.actions.createOrUpdateRepoSecret({\n owner,\n repo,\n secret_name: key,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyResponse.data.key_id,\n });\n }\n }\n\n if (oidcCustomization) {\n await client.request(\n 'PUT /repos/{owner}/{repo}/actions/oidc/customization/sub',\n {\n owner,\n repo,\n use_default: oidcCustomization.useDefault,\n include_claim_keys: oidcCustomization.includeClaimKeys,\n },\n );\n }\n\n if (subscribe) {\n await client.rest.activity.setRepoSubscription({\n subscribed: true,\n ignored: false,\n owner,\n repo,\n });\n }\n\n if (workflowAccess) {\n await client.rest.actions.setWorkflowAccessToRepository({\n access_level: workflowAccess,\n owner,\n repo,\n });\n }\n\n return newRepo;\n}\n\nexport async function initRepoPushAndProtect(\n remoteUrl: string,\n password: string,\n workspacePath: string,\n sourcePath: string | undefined,\n defaultBranch: string,\n protectDefaultBranch: boolean,\n enforceAdmins: boolean,\n owner: string,\n client: Octokit,\n repo: string,\n requireCodeOwnerReviews: boolean,\n bypassPullRequestAllowances:\n | {\n users?: string[];\n teams?: string[];\n apps?: string[];\n }\n | undefined,\n requiredApprovingReviewCount: number,\n restrictions:\n | {\n users: string[];\n teams: string[];\n apps?: string[];\n }\n | undefined,\n requiredStatusCheckContexts: string[],\n requireBranchesToBeUpToDate: boolean,\n requiredConversationResolution: boolean,\n requireLastPushApproval: boolean,\n config: Config,\n logger: any,\n gitCommitMessage?: string,\n gitAuthorName?: string,\n gitAuthorEmail?: string,\n dismissStaleReviews?: boolean,\n requiredCommitSigning?: boolean,\n requiredLinearHistory?: boolean,\n): Promise<{ commitHash: string }> {\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n const commitMessage =\n getGitCommitMessage(gitCommitMessage, config) || 'initial commit';\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(workspacePath, sourcePath),\n remoteUrl,\n defaultBranch,\n auth: {\n username: 'x-access-token',\n password,\n },\n logger,\n commitMessage,\n gitAuthorInfo,\n });\n\n if (protectDefaultBranch) {\n try {\n await enableBranchProtectionOnDefaultRepoBranch({\n owner,\n client,\n repoName: repo,\n logger,\n defaultBranch,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requireCodeOwnerReviews,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n enforceAdmins,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n });\n } catch (e) {\n assertError(e);\n logger.warn(\n `Skipping: default branch protection on '${repo}', ${e.message}`,\n );\n }\n }\n\n return { commitHash: commitResult.commitHash };\n}\n\nfunction extractCollaboratorName(\n collaborator: { user: string } | { team: string } | { username: string },\n) {\n if ('username' in collaborator) return collaborator.username;\n if ('user' in collaborator) return collaborator.user;\n return collaborator.team;\n}\n\nasync function validateAccessTeam(client: Octokit, access: string) {\n const [org, team_slug] = access.split('/');\n try {\n // Below rule disabled because of a 'getByName' check for a different library\n // incorrectly triggers here.\n // eslint-disable-next-line testing-library/no-await-sync-queries\n await client.rest.teams.getByName({\n org,\n team_slug,\n });\n } catch (e) {\n if (e.response.data.message === 'Not Found') {\n const message = `Received 'Not Found' from the API; one of org:\n ${org} or team: ${team_slug} was not found within GitHub.`;\n throw new NotFoundError(message);\n }\n }\n}\n\nexport function getGitCommitMessage(\n gitCommitMessage: string | undefined,\n config: Config,\n): string | undefined {\n return gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage');\n}\n"],"names":["assertError","entityRefToName","Sodium","initRepoAndPush","getRepoSourceDirectory","enableBranchProtectionOnDefaultRepoBranch","NotFoundError"],"mappings":";;;;;;;;;;;AAgCA,eAAsB,0CAAA,CACpB,MAAA,EACA,IAAA,EACA,KAAA,EACA,cAAA,EACA,WAAA,EACA,QAAA,EACA,mBAAA,EACA,gBAAA,EACA,gBAAA,EACA,sBAAA,EACA,wBAAA,EACA,gBAAA,EACA,cAAA,EACA,iBAAA,EACA,MAAA,EACA,aAAA,EAiBA,WAAA,EACA,OAAA,EACA,SAAA,EACA,MAAA,EACA,aAAA,EACA,OAAA,EACA,iBAAA,EAMA,gBAAA,EACA,SAAA,EACA,MAAA,EACA,QAAA,EACA,cAAA,EACA;AACA,EAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,IAAA,CAAK,MAAM,aAAA,CAAc;AAAA,IACjD,QAAA,EAAU;AAAA,GACX,CAAA;AAED,EAAA,IAAI,MAAA,EAAQ,UAAA,CAAW,CAAA,EAAG,KAAK,GAAG,CAAA,EAAG;AACnC,IAAA,MAAM,kBAAA,CAAmB,QAAQ,MAAM,CAAA;AAAA,EACzC;AAEA,EAAA,MAAM,cAAA,GAAiB;AAAA,IACrB,gBAAA,EAAkB,cAAA;AAAA,IAClB,kBAAA,EAAoB,gBAAA;AAAA,IACpB,kBAAA,EAAoB,gBAAA;AAAA,IACpB,kBAAA,EAAoB,gBAAA;AAAA,IACpB,mBAAA,EAAqB,iBAAA;AAAA,IACrB,SAAA,EAAW,QAAA;AAAA,IACX,sBAAA,EAAwB,mBAAA;AAAA,IACxB,WAAA;AAAA,IACA,UAAA,EAAY,SAAA;AAAA,IACZ,YAAA,EAAc,WAAA;AAAA,IACd,QAAA,EAAU,OAAA;AAAA,IACV,QAAA;AAAA,IACA,IAAA,EAAM,IAAA;AAAA,IACN,SAAS,cAAA,KAAmB,SAAA;AA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kBAAA,CAAY,CAAC,CAAA;AACb,MAAA,MAAA,CAAO,IAAA;AAAA,QACL,CAAA,wCAAA,EAA2C,IAAI,CAAA,GAAA,EAAM,CAAA,CAAE,OAAO,CAAA;AAAA,OAChE;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,UAAA,EAAY,YAAA,CAAa,UAAA,EAAW;AAC/C;AAEA,SAAS,wBACP,YAAA,EACA;AACA,EAAA,IAAI,UAAA,IAAc,YAAA,EAAc,OAAO,YAAA,CAAa,QAAA;AACpD,EAAA,IAAI,MAAA,IAAU,YAAA,EAAc,OAAO,YAAA,CAAa,IAAA;AAChD,EAAA,OAAO,YAAA,CAAa,IAAA;AACtB;AAEA,eAAe,kBAAA,CAAmB,QAAiB,MAAA,EAAgB;AACjE,EAAA,MAAM,CAAC,GAAA,EAAK,SAAS,CAAA,GAAI,MAAA,CAAO,MAAM,GAAG,CAAA;AACzC,EAAA,IAAI;AAIF,IAAA,MAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,SAAA,CAAU;AAAA,MAChC,GAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH,SAAS,CAAA,EAAG;AACV,IAAA,IAAI,CAAA,CAAE,QAAA,CAAS,IAAA,CAAK,OAAA,KAAY,WAAA,EAAa;AAC3C,MAAA,MAAM,OAAA,GAAU,CAAA;AAAA,QAAA,EACZ,GAAG,aAAa,SAAS,CAAA,6BAAA,CAAA;AAC7B,MAAA,MAAM,IAAIM,qBAAc,OAAO,CAAA;AAAA,IACjC;AAAA,EACF;AACF;AAEO,SAAS,mBAAA,CACd,kBACA,MAAA,EACoB;AACpB,EAAA,OAAO,gBAAA,GACH,gBAAA,GACA,MAAA,CAAO,iBAAA,CAAkB,iCAAiC,CAAA;AAChE;;;;;;"}
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { NotFoundError, toError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\n\nimport {\n getRepoSourceDirectory,\n initRepoAndPush,\n} from '@backstage/plugin-scaffolder-node';\n\nimport Sodium from 'libsodium-wrappers';\nimport {\n enableBranchProtectionOnDefaultRepoBranch,\n entityRefToName,\n} from './gitHelpers';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nexport async function createGithubRepoWithCollaboratorsAndTopics(\n client: Octokit,\n repo: string,\n owner: string,\n repoVisibility: 'private' | 'internal' | 'public' | undefined,\n description: string | undefined,\n homepage: string | undefined,\n deleteBranchOnMerge: boolean,\n allowMergeCommit: boolean,\n allowSquashMerge: boolean,\n squashMergeCommitTitle: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE' | undefined,\n squashMergeCommitMessage: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK' | undefined,\n allowRebaseMerge: boolean,\n allowAutoMerge: boolean,\n allowUpdateBranch: boolean,\n access: string | undefined,\n collaborators:\n | (\n | {\n user: string;\n access: string;\n }\n | {\n team: string;\n access: string;\n }\n | {\n /** @deprecated This field is deprecated in favor of team */\n username: string;\n access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';\n }\n )[]\n | undefined,\n hasProjects: boolean | undefined,\n hasWiki: boolean | undefined,\n hasIssues: boolean | undefined,\n topics: string[] | undefined,\n repoVariables: { [key: string]: string } | undefined,\n secrets: { [key: string]: string } | undefined,\n oidcCustomization:\n | {\n useDefault: boolean;\n includeClaimKeys?: string[];\n }\n | undefined,\n customProperties: { [key: string]: string | string[] } | undefined,\n subscribe: boolean | undefined,\n logger: LoggerService,\n autoInit?: boolean | undefined,\n workflowAccess?: 'none' | 'organization' | 'user',\n) {\n const user = await client.rest.users.getByUsername({\n username: owner,\n });\n\n if (access?.startsWith(`${owner}/`)) {\n await validateAccessTeam(client, access);\n }\n\n const baseRepoParams = {\n allow_auto_merge: allowAutoMerge,\n allow_merge_commit: allowMergeCommit,\n allow_rebase_merge: allowRebaseMerge,\n allow_squash_merge: allowSquashMerge,\n allow_update_branch: allowUpdateBranch,\n auto_init: autoInit,\n delete_branch_on_merge: deleteBranchOnMerge,\n description,\n has_issues: hasIssues,\n has_projects: hasProjects,\n has_wiki: hasWiki,\n homepage,\n name: repo,\n private: repoVisibility === 'private',\n squash_merge_commit_message: squashMergeCommitMessage,\n squash_merge_commit_title: squashMergeCommitTitle,\n };\n const repoCreationPromise =\n user.data.type === 'Organization'\n ? client.rest.repos.createInOrg({\n ...baseRepoParams,\n // Custom properties only available on org repos\n custom_properties: customProperties,\n org: owner,\n // @ts-ignore https://github.com/octokit/types.ts/issues/522\n visibility: repoVisibility,\n })\n : client.rest.repos.createForAuthenticatedUser(baseRepoParams);\n\n let newRepo;\n\n try {\n newRepo = (await repoCreationPromise).data;\n } catch (e) {\n if (toError(e).message === 'Resource not accessible by integration') {\n logger.warn(\n `The GitHub app or token provided may not have the required permissions to create the ${user.data.type} repository ${owner}/${repo}.`,\n );\n }\n throw new Error(\n `Failed to create the ${user.data.type} repository ${owner}/${repo}, ${\n toError(e).message\n }`,\n );\n }\n\n if (access?.startsWith(`${owner}/`)) {\n const [, team] = access.split('/');\n await client.rest.teams.addOrUpdateRepoPermissionsInOrg({\n org: owner,\n team_slug: team,\n owner,\n repo,\n permission: 'admin',\n });\n // No need to add access if it's the person who owns the personal account\n } else if (access && access !== owner) {\n await client.rest.repos.addCollaborator({\n owner,\n repo,\n username: access,\n permission: 'admin',\n });\n }\n\n if (collaborators) {\n for (const collaborator of collaborators) {\n try {\n if ('user' in collaborator) {\n await client.rest.repos.addCollaborator({\n owner,\n repo,\n username: entityRefToName(collaborator.user),\n permission: collaborator.access,\n });\n } else if ('team' in collaborator) {\n await client.rest.teams.addOrUpdateRepoPermissionsInOrg({\n org: owner,\n team_slug: entityRefToName(collaborator.team),\n owner,\n repo,\n permission: collaborator.access,\n });\n }\n } catch (e) {\n const name = extractCollaboratorName(collaborator);\n logger.warn(\n `Skipping ${collaborator.access} access for ${name}, ${\n toError(e).message\n }`,\n );\n }\n }\n }\n\n if (topics) {\n try {\n await client.rest.repos.replaceAllTopics({\n owner,\n repo,\n names: topics.map(t => t.toLowerCase()),\n });\n } catch (e) {\n logger.warn(`Skipping topics ${topics.join(' ')}, ${toError(e).message}`);\n }\n }\n\n for (const [key, value] of Object.entries(repoVariables ?? {})) {\n await client.rest.actions.createRepoVariable({\n owner,\n repo,\n name: key,\n value: value,\n });\n }\n\n if (secrets) {\n const publicKeyResponse = await client.rest.actions.getRepoPublicKey({\n owner,\n repo,\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKeyResponse.data.key,\n Sodium.base64_variants.ORIGINAL,\n );\n for (const [key, value] of Object.entries(secrets)) {\n const binarySecret = Sodium.from_string(value);\n const encryptedBinarySecret = Sodium.crypto_box_seal(\n binarySecret,\n binaryKey,\n );\n const encryptedBase64Secret = Sodium.to_base64(\n encryptedBinarySecret,\n Sodium.base64_variants.ORIGINAL,\n );\n\n await client.rest.actions.createOrUpdateRepoSecret({\n owner,\n repo,\n secret_name: key,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyResponse.data.key_id,\n });\n }\n }\n\n if (oidcCustomization) {\n await client.request(\n 'PUT /repos/{owner}/{repo}/actions/oidc/customization/sub',\n {\n owner,\n repo,\n use_default: oidcCustomization.useDefault,\n include_claim_keys: oidcCustomization.includeClaimKeys,\n },\n );\n }\n\n if (subscribe) {\n await client.rest.activity.setRepoSubscription({\n subscribed: true,\n ignored: false,\n owner,\n repo,\n });\n }\n\n if (workflowAccess) {\n await client.rest.actions.setWorkflowAccessToRepository({\n access_level: workflowAccess,\n owner,\n repo,\n });\n }\n\n return newRepo;\n}\n\nexport async function initRepoPushAndProtect(\n remoteUrl: string,\n password: string,\n workspacePath: string,\n sourcePath: string | undefined,\n defaultBranch: string,\n protectDefaultBranch: boolean,\n enforceAdmins: boolean,\n owner: string,\n client: Octokit,\n repo: string,\n requireCodeOwnerReviews: boolean,\n bypassPullRequestAllowances:\n | {\n users?: string[];\n teams?: string[];\n apps?: string[];\n }\n | undefined,\n requiredApprovingReviewCount: number,\n restrictions:\n | {\n users: string[];\n teams: string[];\n apps?: string[];\n }\n | undefined,\n requiredStatusCheckContexts: string[],\n requireBranchesToBeUpToDate: boolean,\n requiredConversationResolution: boolean,\n requireLastPushApproval: boolean,\n config: Config,\n logger: any,\n gitCommitMessage?: string,\n gitAuthorName?: string,\n gitAuthorEmail?: string,\n dismissStaleReviews?: boolean,\n requiredCommitSigning?: boolean,\n requiredLinearHistory?: boolean,\n): Promise<{ commitHash: string }> {\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n const commitMessage =\n getGitCommitMessage(gitCommitMessage, config) || 'initial commit';\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(workspacePath, sourcePath),\n remoteUrl,\n defaultBranch,\n auth: {\n username: 'x-access-token',\n password,\n },\n logger,\n commitMessage,\n gitAuthorInfo,\n });\n\n if (protectDefaultBranch) {\n try {\n await enableBranchProtectionOnDefaultRepoBranch({\n owner,\n client,\n repoName: repo,\n logger,\n defaultBranch,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requireCodeOwnerReviews,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n enforceAdmins,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n });\n } catch (e) {\n logger.warn(\n `Skipping: default branch protection on '${repo}', ${\n toError(e).message\n }`,\n );\n }\n }\n\n return { commitHash: commitResult.commitHash };\n}\n\nfunction extractCollaboratorName(\n collaborator: { user: string } | { team: string } | { username: string },\n) {\n if ('username' in collaborator) {\n return collaborator.username;\n }\n if ('user' in collaborator) {\n return collaborator.user;\n }\n return collaborator.team;\n}\n\nasync function validateAccessTeam(client: Octokit, access: string) {\n const [org, team_slug] = access.split('/');\n try {\n // Below rule disabled because of a 'getByName' check for a different library\n // incorrectly triggers here.\n // eslint-disable-next-line testing-library/no-await-sync-queries\n await client.rest.teams.getByName({\n org,\n team_slug,\n });\n } catch (e) {\n if (e.response.data.message === 'Not Found') {\n const message = `Received 'Not Found' from the API; one of org:\n ${org} or team: ${team_slug} was not found within GitHub.`;\n throw new NotFoundError(message);\n }\n }\n}\n\nexport function getGitCommitMessage(\n gitCommitMessage: string | undefined,\n config: Config,\n): string | undefined {\n return gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage');\n}\n"],"names":["toError","entityRefToName","Sodium","initRepoAndPush","getRepoSourceDirectory","enableBranchProtectionOnDefaultRepoBranch","NotFoundError"],"mappings":";;;;;;;;;;;AAgCA,eAAsB,0CAAA,CACpB,MAAA,EACA,IAAA,EACA,KAAA,EACA,cAAA,EACA,WAAA,EACA,QAAA,EACA,mBAAA,EACA,gBAAA,EACA,gBAAA,EACA,sBAAA,EACA,wBAAA,EACA,gBAAA,EACA,cAAA,EACA,iBAAA,EACA,MAAA,EACA,aAAA,EAiBA,WAAA,EACA,OAAA,EACA,SAAA,EACA,MAAA,EACA,aAAA,EACA,OAAA,EACA,iBAAA,EAMA,gBAAA,EACA,SAAA,EACA,MAAA,EACA,QAAA,EACA,cAAA,EACA;AACA,EAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,IAAA,CAAK,MAAM,aAAA,CAAc;AAAA,IACjD,QAAA,EAAU;AAAA,GACX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AK,KAAA,CAAM,SAAA,CAAU;AAAA,MAChC,GAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH,SAAS,CAAA,EAAG;AACV,IAAA,IAAI,CAAA,CAAE,QAAA,CAAS,IAAA,CAAK,OAAA,KAAY,WAAA,EAAa;AAC3C,MAAA,MAAM,OAAA,GAAU,CAAA;AAAA,QAAA,EACZ,GAAG,aAAa,SAAS,CAAA,6BAAA,CAAA;AAC7B,MAAA,MAAM,IAAIM,qBAAc,OAAO,CAAA;AAAA,IACjC;AAAA,EACF;AACF;AAEO,SAAS,mBAAA,CACd,kBACA,MAAA,EACoB;AACpB,EAAA,OAAO,gBAAA,GACH,gBAAA,GACA,MAAA,CAAO,iBAAA,CAAkB,iCAAiC,CAAA;AAChE;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-github",
3
- "version": "0.9.8-next.1",
3
+ "version": "0.9.8-next.2",
4
4
  "description": "The github module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -50,13 +50,13 @@
50
50
  "test": "backstage-cli package test"
51
51
  },
52
52
  "dependencies": {
53
- "@backstage/backend-plugin-api": "1.9.0-next.1",
54
- "@backstage/catalog-model": "1.7.7",
55
- "@backstage/config": "1.3.6",
56
- "@backstage/errors": "1.2.7",
57
- "@backstage/integration": "2.0.0",
58
- "@backstage/plugin-catalog-node": "2.1.1-next.1",
59
- "@backstage/plugin-scaffolder-node": "0.13.1-next.1",
53
+ "@backstage/backend-plugin-api": "1.9.0-next.2",
54
+ "@backstage/catalog-model": "1.7.8-next.0",
55
+ "@backstage/config": "1.3.7-next.0",
56
+ "@backstage/errors": "1.3.0-next.0",
57
+ "@backstage/integration": "2.0.1-next.0",
58
+ "@backstage/plugin-catalog-node": "2.2.0-next.2",
59
+ "@backstage/plugin-scaffolder-node": "0.13.2-next.2",
60
60
  "@backstage/types": "1.2.2",
61
61
  "@octokit/webhooks": "^10.9.2",
62
62
  "libsodium-wrappers": "^0.8.0",
@@ -66,8 +66,8 @@
66
66
  "zod": "^3.25.76 || ^4.0.0"
67
67
  },
68
68
  "devDependencies": {
69
- "@backstage/backend-test-utils": "1.11.2-next.1",
70
- "@backstage/cli": "0.36.1-next.1",
69
+ "@backstage/backend-test-utils": "1.11.2-next.2",
70
+ "@backstage/cli": "0.36.1-next.2",
71
71
  "@backstage/plugin-scaffolder-node-test-utils": "0.3.10-next.1",
72
72
  "@types/libsodium-wrappers": "^0.8.0",
73
73
  "fs-extra": "^11.2.0",