@backstage/plugin-scaffolder-backend-module-github 0.10.0 → 0.10.1-next.0

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/actions/gitHelpers.cjs.js.map +1 -1
  3. package/dist/actions/gitHubEnvironment.examples.cjs.js.map +1 -1
  4. package/dist/actions/github.cjs.js.map +1 -1
  5. package/dist/actions/github.examples.cjs.js.map +1 -1
  6. package/dist/actions/githubActionsDispatch.cjs.js.map +1 -1
  7. package/dist/actions/githubActionsDispatch.examples.cjs.js.map +1 -1
  8. package/dist/actions/githubAutolinks.cjs.js.map +1 -1
  9. package/dist/actions/githubAutolinks.examples.cjs.js.map +1 -1
  10. package/dist/actions/githubBranchProtection.cjs.js.map +1 -1
  11. package/dist/actions/githubBranchProtection.examples.cjs.js.map +1 -1
  12. package/dist/actions/githubDeployKey.cjs.js.map +1 -1
  13. package/dist/actions/githubDeployKey.examples.cjs.js.map +1 -1
  14. package/dist/actions/githubEnvironment.cjs.js.map +1 -1
  15. package/dist/actions/githubIssuesCreate.cjs.js.map +1 -1
  16. package/dist/actions/githubIssuesCreate.examples.cjs.js.map +1 -1
  17. package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
  18. package/dist/actions/githubIssuesLabel.examples.cjs.js.map +1 -1
  19. package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
  20. package/dist/actions/githubPagesEnable.examples.cjs.js.map +1 -1
  21. package/dist/actions/githubPullRequest.cjs.js.map +1 -1
  22. package/dist/actions/githubPullRequest.examples.cjs.js.map +1 -1
  23. package/dist/actions/githubRepoCreate.cjs.js.map +1 -1
  24. package/dist/actions/githubRepoCreate.examples.cjs.js.map +1 -1
  25. package/dist/actions/githubRepoPush.cjs.js.map +1 -1
  26. package/dist/actions/githubRepoPush.examples.cjs.js.map +1 -1
  27. package/dist/actions/githubWebhook.cjs.js.map +1 -1
  28. package/dist/actions/githubWebhook.examples.cjs.js.map +1 -1
  29. package/dist/actions/helpers.cjs.js.map +1 -1
  30. package/dist/actions/inputProperties.cjs.js.map +1 -1
  31. package/dist/actions/outputProperties.cjs.js.map +1 -1
  32. package/dist/autocomplete/autocomplete.cjs.js.map +1 -1
  33. package/dist/module.cjs.js.map +1 -1
  34. package/dist/util.cjs.js.map +1 -1
  35. package/package.json +12 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-github
2
2
 
3
+ ## 0.10.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/integration@2.1.3-next.0
9
+ - @backstage/config@1.3.10-next.0
10
+ - @backstage/errors@1.3.2-next.0
11
+ - @backstage/plugin-scaffolder-node@0.13.8-next.0
12
+ - @backstage/backend-plugin-api@1.10.2-next.0
13
+ - @backstage/catalog-model@1.10.2-next.0
14
+ - @backstage/plugin-catalog-node@2.2.6-next.0
15
+
3
16
  ## 0.10.0
4
17
 
5
18
  ### Minor Changes
@@ -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 { 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,EAAw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AAA,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;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AAA,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;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"gitHubEnvironment.examples.cjs.js","sources":["../../src/actions/gitHubEnvironment.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Create a GitHub Environment (No Policies, No Variables, No Secrets)',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Protected Branch Policy',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: true,\n custom_branch_policies: false,\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Custom Branch Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['main', '*.*.*'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Environment Variables and Secrets',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n key1: 'val1',\n key2: 'val2',\n },\n secrets: {\n secret1: 'supersecret1',\n secret2: 'supersecret2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Custom Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n customTagPolicyNames: ['release/*/*', 'v*.*.*'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Both Branch and Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['feature/*', 'hotfix/*'],\n customTagPolicyNames: ['release/*', 'v*'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Full Configuration',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['dev/*', 'test/*'],\n customTagPolicyNames: ['v1.*', 'v2.*'],\n environmentVariables: {\n API_KEY: '123456789',\n NODE_ENV: 'production',\n },\n secrets: {\n DATABASE_URL: 'supersecretdatabaseurl',\n API_SECRET: 'supersecretapisecret',\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Only Token Authentication',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with No Deployment Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: null,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Custom Branch and Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['release/*', 'hotfix/*'],\n customTagPolicyNames: ['v*', 'release-*'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Environment Variables Only',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n VAR1: 'value1',\n VAR2: 'value2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Deployment Secrets Only',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n secrets: {\n SECRET1: 'secretvalue1',\n SECRET2: 'secretvalue2',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Deployment Branch Policy and Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: true,\n custom_branch_policies: false,\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Environment Variables, Secrets, and Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n VAR1: 'value1',\n VAR2: 'value2',\n },\n secrets: {\n SECRET1: 'secretvalue1',\n SECRET2: 'secretvalue2',\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Wait Timer',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n waitTimer: 1000,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Prevent Self Review',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n preventSelfReview: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n reviewers: ['group:default/team-a', 'user:default/johndoe'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,qEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM;AAAA;AACR;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,0DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM,SAAA;AAAA,YACN,sBAAA,EAAwB;AAAA,cACtB,kBAAA,EAAoB,IAAA;AAAA,cACpB,sBAAA,EAAwB;AAAA;AAC1B;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,yDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL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R;AAAA,YACA,OAAA,EAAS;AAAA,cACP,OAAA,EAAS,cAAA;AAAA,cACT,OAAA,EAAS;AAAA,aACX;AAAA,YACA,KAAA,EAAO;AAAA;AACT;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,6CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM,SAAA;AAAA,YACN,SAAA,EAAW;AAAA;AACb;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,sDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM,SAAA;AAAA,YACN,iBAAA,EAAmB;AAAA;AACrB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,4CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM,SAAA;AAAA,YACN,SAAA,EAAW,CAAC,sBAAA,EAAwB,sBAAsB;AAAA;AAC5D;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"gitHubEnvironment.examples.cjs.js","sources":["../../src/actions/gitHubEnvironment.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Create a GitHub Environment (No Policies, No Variables, No Secrets)',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Protected Branch Policy',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: true,\n custom_branch_policies: false,\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Custom Branch Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['main', '*.*.*'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Environment Variables and Secrets',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n key1: 'val1',\n key2: 'val2',\n },\n secrets: {\n secret1: 'supersecret1',\n secret2: 'supersecret2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Custom Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n customTagPolicyNames: ['release/*/*', 'v*.*.*'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Both Branch and Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['feature/*', 'hotfix/*'],\n customTagPolicyNames: ['release/*', 'v*'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Full Configuration',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['dev/*', 'test/*'],\n customTagPolicyNames: ['v1.*', 'v2.*'],\n environmentVariables: {\n API_KEY: '123456789',\n NODE_ENV: 'production',\n },\n secrets: {\n DATABASE_URL: 'supersecretdatabaseurl',\n API_SECRET: 'supersecretapisecret',\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Only Token Authentication',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with No Deployment Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: null,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Custom Branch and Tag Policies',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: false,\n custom_branch_policies: true,\n },\n customBranchPolicyNames: ['release/*', 'hotfix/*'],\n customTagPolicyNames: ['v*', 'release-*'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Environment Variables Only',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n VAR1: 'value1',\n VAR2: 'value2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Deployment Secrets Only',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n secrets: {\n SECRET1: 'secretvalue1',\n SECRET2: 'secretvalue2',\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Deployment Branch Policy and Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n deploymentBranchPolicy: {\n protected_branches: true,\n custom_branch_policies: false,\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitHub Environment with Environment Variables, Secrets, and Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n environmentVariables: {\n VAR1: 'value1',\n VAR2: 'value2',\n },\n secrets: {\n SECRET1: 'secretvalue1',\n SECRET2: 'secretvalue2',\n },\n token: 'ghp_abcdef1234567890',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Wait Timer',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n waitTimer: 1000,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Prevent Self Review',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n preventSelfReview: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitHub Environment with Reviewers',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:environment:create',\n name: 'Create Environment',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n name: 'envname',\n reviewers: ['group:default/team-a', 'user:default/johndoe'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,qEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM;AAAA;AACR;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,0DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,2BAAA;AAAA,UACR,IAAA,EAAM,oBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM,SAAA;AAAA,YACN,sBAAA,EAAwB;AAAA,cACtB,kBAAA,EAAoB,IAAA;AAAA,cACpB,sBAA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A;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,IAAA,EAAM,SAAA;AAAA,YACN,SAAA,EAAW,CAAC,sBAAA,EAAwB,sBAAsB;AAAA;AAC5D;AACF;AACF,KACD;AAAA;AAEL;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"github.cjs.js","sources":["../../src/actions/github.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 { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n createGithubRepoWithCollaboratorsAndTopics,\n initRepoPushAndProtect,\n} from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './github.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitHub.\n *\n * @public\n */\nexport function createPublishGithubAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n githubCredentialsProvider?: GithubCredentialsProvider;\n requireScmUserCredentials?: boolean;\n}) {\n const {\n integrations,\n config,\n githubCredentialsProvider,\n requireScmUserCredentials,\n } = options;\n\n return createTemplateAction({\n id: 'publish:github',\n description:\n 'Initializes a git repository of contents in workspace and publishes it to GitHub.',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n repoVisibility: inputProps.repoVisibility,\n defaultBranch: inputProps.defaultBranch,\n protectDefaultBranch: inputProps.protectDefaultBranch,\n protectEnforceAdmins: inputProps.protectEnforceAdmins,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n gitCommitMessage: inputProps.gitCommitMessage,\n gitAuthorName: inputProps.gitAuthorName,\n gitAuthorEmail: inputProps.gitAuthorEmail,\n allowMergeCommit: inputProps.allowMergeCommit,\n allowSquashMerge: inputProps.allowSquashMerge,\n squashMergeCommitTitle: inputProps.squashMergeCommitTitle,\n squashMergeCommitMessage: inputProps.squashMergeCommitMessage,\n allowRebaseMerge: inputProps.allowRebaseMerge,\n allowAutoMerge: inputProps.allowAutoMerge,\n allowUpdateBranch: inputProps.allowUpdateBranch,\n sourcePath: inputProps.sourcePath,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n },\n output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n commitHash: outputProps.commitHash,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\n requireCodeOwnerReviews = false,\n dismissStaleReviews = false,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount = 1,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n repoVisibility = 'private',\n defaultBranch = 'main',\n protectDefaultBranch = true,\n protectEnforceAdmins = true,\n deleteBranchOnMerge = false,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n allowMergeCommit = true,\n allowSquashMerge = true,\n squashMergeCommitTitle = 'COMMIT_OR_PR_TITLE',\n squashMergeCommitMessage = 'COMMIT_MESSAGES',\n allowRebaseMerge = true,\n allowAutoMerge = false,\n allowUpdateBranch = false,\n collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n token: providedToken,\n customProperties,\n subscribe = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n } = ctx.input;\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 requireScmUserCredentials,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const { remoteUrl, repoContentsUrl } = await ctx.checkpoint({\n key: `create.github.repo.${owner}.${repo}`,\n fn: async () => {\n const newRepo = await createGithubRepoWithCollaboratorsAndTopics(\n client,\n repo,\n owner,\n repoVisibility,\n description,\n homepage,\n deleteBranchOnMerge,\n allowMergeCommit,\n allowSquashMerge,\n squashMergeCommitTitle,\n squashMergeCommitMessage,\n allowRebaseMerge,\n allowAutoMerge,\n allowUpdateBranch,\n access,\n collaborators,\n hasProjects,\n hasWiki,\n hasIssues,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n ctx.logger,\n );\n\n return {\n remoteUrl: newRepo.clone_url,\n repoContentsUrl: `${newRepo.html_url}/blob/${defaultBranch}`,\n };\n },\n });\n\n const commitResult = await initRepoPushAndProtect(\n remoteUrl,\n octokitOptions.auth,\n ctx.workspacePath,\n ctx.input.sourcePath,\n defaultBranch,\n protectDefaultBranch,\n protectEnforceAdmins,\n owner,\n client,\n repo,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n config,\n ctx.logger,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n );\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.repoVisibility","inputProps.defaultBranch","inputProps.protectDefaultBranch","inputProps.protectEnforceAdmins","inputProps.deleteBranchOnMerge","inputProps.gitCommitMessage","inputProps.gitAuthorName","inputProps.gitAuthorEmail","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.sourcePath","inputProps.collaborators","inputProps.hasProjects","inputProps.hasWiki","inputProps.hasIssues","inputProps.token","inputProps.topics","inputProps.repoVariables","inputProps.secrets","inputProps.oidcCustomization","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.customProperties","inputProps.subscribe","outputProps.remoteUrl","outputProps.repoContentsUrl","outputProps.commitHash","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics","initRepoPushAndProtect"],"mappings":";;;;;;;;;;;AA0CO,SAAS,0BAA0B,OAAA,EAKvC;AACD,EAAA,MAAM;AAAA,IACJ,YAAA;AAAA,IACA,MAAA;AAAA,IACA,yBAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EACE,mFAAA;AAAA,cACFC,wBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,aAAaC,2BAAW;AAAA,QACxB,UAAUC,wBAAW;AAAA,QACrB,QAAQC,sBAAW;AAAA,QACnB,6BAA6BC,2CAAW;AAAA,QACxC,8BAA8BC,4CAAW;AAAA,QACzC,cAAcC,4BAAW;AAAA,QACzB,yBAAyBC,uCAAW;AAAA,QACpC,qBAAqBC,mCAAW;AAAA,QAChC,6BAA6BC,2CAAW;AAAA,QACxC,6BAA6BC,2CAAW;AAAA,QACxC,gCACEC,8CAAW;AAAA,QACb,yBAAyBC,uCAAW;AAAA,QACpC,gBAAgBC,8BAAW;AAAA,QAC3B,eAAeC,6BAAW;AAAA,QAC1B,sBAAsBC,oCAAW;AAAA,QACjC,sBAAsBC,oCAAW;AAAA,QACjC,qBAAqBC,mCAAW;AAAA,QAChC,kBAAkBC,gCAAW;AAAA,QAC7B,eAAeC,6BAAW;AAAA,QAC1B,gBAAgBC,8BAAW;AAAA,QAC3B,kBAAkBC,gCAAW;AAAA,QAC7B,kBAAkBC,gCAAW;AAAA,QAC7B,wBAAwBC,sCAAW;AAAA,QACnC,0BAA0BC,wCAAW;AAAA,QACrC,kBAAkBC,gCAAW;AAAA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O,YAAA,EAAc,YAAA,EAAc,UAAU,CAAA;AACjD,MAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAA,GAAA,CAAI,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA,IAC/C;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"github.cjs.js","sources":["../../src/actions/github.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 { Config } from '@backstage/config';\nimport { InputError } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n createGithubRepoWithCollaboratorsAndTopics,\n initRepoPushAndProtect,\n} from './helpers';\nimport { getOctokitOptions } from '../util';\nimport * as inputProps from './inputProperties';\nimport * as outputProps from './outputProperties';\nimport { examples } from './github.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitHub.\n *\n * @public\n */\nexport function createPublishGithubAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n githubCredentialsProvider?: GithubCredentialsProvider;\n requireScmUserCredentials?: boolean;\n}) {\n const {\n integrations,\n config,\n githubCredentialsProvider,\n requireScmUserCredentials,\n } = options;\n\n return createTemplateAction({\n id: 'publish:github',\n description:\n 'Initializes a git repository of contents in workspace and publishes it to GitHub.',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n description: inputProps.description,\n homepage: inputProps.homepage,\n access: inputProps.access,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n restrictions: inputProps.restrictions,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n repoVisibility: inputProps.repoVisibility,\n defaultBranch: inputProps.defaultBranch,\n protectDefaultBranch: inputProps.protectDefaultBranch,\n protectEnforceAdmins: inputProps.protectEnforceAdmins,\n deleteBranchOnMerge: inputProps.deleteBranchOnMerge,\n gitCommitMessage: inputProps.gitCommitMessage,\n gitAuthorName: inputProps.gitAuthorName,\n gitAuthorEmail: inputProps.gitAuthorEmail,\n allowMergeCommit: inputProps.allowMergeCommit,\n allowSquashMerge: inputProps.allowSquashMerge,\n squashMergeCommitTitle: inputProps.squashMergeCommitTitle,\n squashMergeCommitMessage: inputProps.squashMergeCommitMessage,\n allowRebaseMerge: inputProps.allowRebaseMerge,\n allowAutoMerge: inputProps.allowAutoMerge,\n allowUpdateBranch: inputProps.allowUpdateBranch,\n sourcePath: inputProps.sourcePath,\n collaborators: inputProps.collaborators,\n hasProjects: inputProps.hasProjects,\n hasWiki: inputProps.hasWiki,\n hasIssues: inputProps.hasIssues,\n token: inputProps.token,\n topics: inputProps.topics,\n repoVariables: inputProps.repoVariables,\n secrets: inputProps.secrets,\n oidcCustomization: inputProps.oidcCustomization,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n customProperties: inputProps.customProperties,\n subscribe: inputProps.subscribe,\n },\n output: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n commitHash: outputProps.commitHash,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n homepage,\n access,\n requireCodeOwnerReviews = false,\n dismissStaleReviews = false,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount = 1,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n repoVisibility = 'private',\n defaultBranch = 'main',\n protectDefaultBranch = true,\n protectEnforceAdmins = true,\n deleteBranchOnMerge = false,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n allowMergeCommit = true,\n allowSquashMerge = true,\n squashMergeCommitTitle = 'COMMIT_OR_PR_TITLE',\n squashMergeCommitMessage = 'COMMIT_MESSAGES',\n allowRebaseMerge = true,\n allowAutoMerge = false,\n allowUpdateBranch = false,\n collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n token: providedToken,\n customProperties,\n subscribe = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n } = ctx.input;\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 requireScmUserCredentials,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const { remoteUrl, repoContentsUrl } = await ctx.checkpoint({\n key: `create.github.repo.${owner}.${repo}`,\n fn: async () => {\n const newRepo = await createGithubRepoWithCollaboratorsAndTopics(\n client,\n repo,\n owner,\n repoVisibility,\n description,\n homepage,\n deleteBranchOnMerge,\n allowMergeCommit,\n allowSquashMerge,\n squashMergeCommitTitle,\n squashMergeCommitMessage,\n allowRebaseMerge,\n allowAutoMerge,\n allowUpdateBranch,\n access,\n collaborators,\n hasProjects,\n hasWiki,\n hasIssues,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n subscribe,\n ctx.logger,\n );\n\n return {\n remoteUrl: newRepo.clone_url,\n repoContentsUrl: `${newRepo.html_url}/blob/${defaultBranch}`,\n };\n },\n });\n\n const commitResult = await initRepoPushAndProtect(\n remoteUrl,\n octokitOptions.auth,\n ctx.workspacePath,\n ctx.input.sourcePath,\n defaultBranch,\n protectDefaultBranch,\n protectEnforceAdmins,\n owner,\n client,\n repo,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n config,\n ctx.logger,\n gitCommitMessage,\n gitAuthorName,\n gitAuthorEmail,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n );\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.description","inputProps.homepage","inputProps.access","inputProps.bypassPullRequestAllowances","inputProps.requiredApprovingReviewCount","inputProps.restrictions","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.repoVisibility","inputProps.defaultBranch","inputProps.protectDefaultBranch","inputProps.protectEnforceAdmins","inputProps.deleteBranchOnMerge","inputProps.gitCommitMessage","inputProps.gitAuthorName","inputProps.gitAuthorEmail","inputProps.allowMergeCommit","inputProps.allowSquashMerge","inputProps.squashMergeCommitTitle","inputProps.squashMergeCommitMessage","inputProps.allowRebaseMerge","inputProps.allowAutoMerge","inputProps.allowUpdateBranch","inputProps.sourcePath","inputProps.collaborators","inputProps.hasProjects","inputProps.hasWiki","inputProps.hasIssues","inputProps.token","inputProps.topics","inputProps.repoVariables","inputProps.secrets","inputProps.oidcCustomization","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.customProperties","inputProps.subscribe","outputProps.remoteUrl","outputProps.repoContentsUrl","outputProps.commitHash","parseRepoUrl","InputError","getOctokitOptions","Octokit","createGithubRepoWithCollaboratorsAndTopics","initRepoPushAndProtect"],"mappings":";;;;;;;;;;;AA0CO,SAAS,0BAA0B,OAAA,EAKvC;AACD,EAAA,MAAM;AAAA,IACJ,YAAA;AAAA,IACA,MAAA;AAAA,IACA,yBAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EACE,mFAAA;AAAA,cACFC,wBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,aAAaC,2BAAW;AAAA,QACxB,UAAUC,wBAAW;AAAA,QACrB,QAAQC,sBAAW;AAAA,QACnB,6BAA6BC,2CAAW;AAAA,QACxC,8BAA8BC,4CAAW;AAAA,QACzC,cAAcC,4BAAW;AAAA,QACzB,yBAAyBC,uCAAW;AAAA,QACpC,qBAAqBC,mCAAW;AAAA,QAChC,6BAA6BC,2CAAW;AAAA,QACxC,6BAA6BC,2CAAW;AAAA,QACxC,gCACEC,8CAAW;AAAA,QACb,yBAAyBC,uCAAW;AAAA,QACpC,gBAAgBC,8BAAW;AAAA,QAC3B,eAAeC,6BAAW;AAAA,QAC1B,sBAAsBC,oCAAW;AAAA,QACjC,sBAAsBC,oCAAW;AAAA,QACjC,qBAAqBC,mCAAW;AAAA,QAChC,kBAAkBC,gCAAW;AAAA,QAC7B,eAAeC,6BAAW;AAAA,QAC1B,gBAAgBC,8BAAW;AAAA,QAC3B,kBAAkBC,gCAAW;AAAA,QAC7B,kBAAkBC,gCAAW;AAAA,QAC7B,wBAAwBC,sCAAW;AAAA,QACnC,0BAA0BC,wCAAW;AAAA,QACrC,kBAAkBC,gCAAW;AAAA,Q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YAAA,EAAc,YAAA,EAAc,UAAU,CAAA;AACjD,MAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAA,GAAA,CAAI,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA,IAC/C;AAAA,GACD,CAAA;AACH;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"github.examples.cjs.js","sources":["../../src/actions/github.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository with the content in the workspace, and publishes it to GitHub with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitHub repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitHub repository with public repo visibility, if not set defaults to private',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n repoVisibility: 'public',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,4HAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,qDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,WAAA,EAAa;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,6FAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,cAAA,EAAgB;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"github.examples.cjs.js","sources":["../../src/actions/github.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository with the content in the workspace, and publishes it to GitHub with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a GitHub repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a GitHub repository with public repo visibility, if not set defaults to private',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:github',\n name: 'Publish to GitHub',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n repoVisibility: 'public',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,4HAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,qDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,WAAA,EAAa;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,6FAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,gBAAA;AAAA,UACR,IAAA,EAAM,mBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,cAAA,EAAgB;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;"}
@@ -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 { 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 requireScmUserCredentials?: boolean;\n}) {\n const { integrations, githubCredentialsProvider, requireScmUserCredentials } =\n 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 requireScmUserCredentials,\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":";;;;;;;;AAiCO,SAAS,kCAAkC,OAAA,EAI/C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA2B,yBAAA,EAA0B,GACzE,OAAA;AAEF,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EACE,+DAAA;AAAA,cACFC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A,aACF;AAEA,YAAA,GAAA,CAAI,MAAA,CAAO,IAAA,CAAK,CAAA,SAAA,EAAY,UAAU,CAAA,wBAAA,CAA0B,CAAA;AAEhE,YAAA,IAAI,wBAAA,IAA4B,SAAS,IAAA,EAAM;AAO7C,cAAA,MAAM,OAAO,QAAA,CAAS,IAAA;AAMtB,cAAA,OAAO;AAAA,gBACL,eAAe,IAAA,CAAK,eAAA;AAAA,gBACpB,gBAAgB,IAAA,CAAK,OAAA;AAAA,gBACrB,oBAAoB,IAAA,CAAK;AAAA,eAC3B;AAAA,YACF;AACA,YAAA,OAAO,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,QAAA,MAAM,KAAA,GAAQC,eAAQ,CAAC,CAAA;AACvB,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,iCAAiC,UAAU,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,MAAM,OAAO,CAAA;AAAA,SACnF;AACA,QAAA,MAAM,KAAA;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 requireScmUserCredentials?: boolean;\n}) {\n const { integrations, githubCredentialsProvider, requireScmUserCredentials } =\n 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 requireScmUserCredentials,\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":";;;;;;;;AAiCO,SAAS,kCAAkC,OAAA,EAI/C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA2B,yBAAA,EAA0B,GACzE,OAAA;AAEF,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,SACH,CAAA;AAAA,QACH,gBAAgB,CAAA,CAAA,KACd,CAAA,CACG,MAAA,CAAO,CAAA,CAAE,QAAO,EAAG;AAAA,UAClB,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,wBAAA,EAA0B,CAAA,CAAA,KACxB,CAAA,CACG,OAAA,CAAQ;AAAA,UACP,WAAA,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tD,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,QAAA,MAAM,KAAA,GAAQC,eAAQ,CAAC,CAAA;AACvB,QAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA,UACT,iCAAiC,UAAU,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,MAAM,OAAO,CAAA;AAAA,SACnF;AACA,QAAA,MAAM,KAAA;AAAA,MACR;AAAA,IACF;AAAA,GACD,CAAA;AACH;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubActionsDispatch.examples.cjs.js","sources":["../../src/actions/githubActionsDispatch.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'GitHub Action Workflow Without Inputs.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch Github Action Workflow',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow With Inputs',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch Github Action Workflow with inputs',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n workflowInputs: {\n input1: 'value1',\n input2: 'value2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow With Custom Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch GitHub Action Workflow (custom token)',\n input: {\n repoUrl: 'github.com?repo=reponame&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'release-1.0',\n token: '${{ secrets.MY_CUSTOM_TOKEN }}',\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow returning run details',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch GitHub Action Workflow and get run ID',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n returnWorkflowRunDetails: true,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,iCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,UAAA,EAAY,aAAA;AAAA,YACZ,eAAA,EAAiB;AAAA;AACnB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,oCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,6CAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,UAAA,EAAY,aAAA;AAAA,YACZ,eAAA,EAAiB,MAAA;AAAA,YACjB,cAAA,EAAgB;AAAA,cACd,MAAA,EAAQ,QAAA;AAAA,cACR,MAAA,EAAQ;AAAA;AACV;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,0CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,gDAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,sCAAA;AAAA,YACT,UAAA,EAAY,aAAA;AAAA,YACZ,eAAA,EAAiB,aAAA;AAAA,YACjB,KAAA,EAAO;AAAA;AACT;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,8CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,gDAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,UAAA,EAAY,aAAA;AAAA,YACZ,eAAA,EAAiB,MAAA;AAAA,YACjB,wBAAA,EAA0B;AAAA;AAC5B;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"githubActionsDispatch.examples.cjs.js","sources":["../../src/actions/githubActionsDispatch.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'GitHub Action Workflow Without Inputs.',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch Github Action Workflow',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow With Inputs',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch Github Action Workflow with inputs',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n workflowInputs: {\n input1: 'value1',\n input2: 'value2',\n },\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow With Custom Token',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch GitHub Action Workflow (custom token)',\n input: {\n repoUrl: 'github.com?repo=reponame&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'release-1.0',\n token: '${{ secrets.MY_CUSTOM_TOKEN }}',\n },\n },\n ],\n }),\n },\n {\n description: 'GitHub Action Workflow returning run details',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:actions:dispatch',\n name: 'Dispatch GitHub Action Workflow and get run ID',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n workflowId: 'WORKFLOW_ID',\n branchOrTagName: 'main',\n returnWorkflowRunDetails: true,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA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EAAS,kCAAA;AAAA,YACT,UAAA,EAAY,aAAA;AAAA,YACZ,eAAA,EAAiB,MAAA;AAAA,YACjB,wBAAA,EAA0B;AAAA;AAC5B;AACF;AACF,KACD;AAAA;AAEL;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubAutolinks.cjs.js","sources":["../../src/actions/githubAutolinks.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 } 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 { examples } from './githubAutolinks.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Create an autolink reference for a repository\n * @public\n */\nexport function createGithubAutolinksAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n requireScmUserCredentials?: boolean;\n}) {\n const { integrations, githubCredentialsProvider, requireScmUserCredentials } =\n options;\n\n return createTemplateAction({\n id: 'github:autolinks:create',\n description: 'Create an autolink reference for a repository',\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 keyPrefix: z =>\n z.string({\n description:\n 'This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.',\n }),\n urlTemplate: z =>\n z.string({\n description:\n 'The URL must contain `<num>` for the reference number. `<num>` matches different characters depending on the value of isAlphanumeric.',\n }),\n isAlphanumeric: z =>\n z\n .boolean({\n description:\n '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`',\n })\n .default(true)\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const { repoUrl, keyPrefix, urlTemplate, isAlphanumeric, token } =\n ctx.input;\n\n ctx.logger.info(`Creating autolink reference for repo ${repoUrl}`);\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 requireScmUserCredentials,\n host,\n owner,\n repo,\n credentialsProvider: githubCredentialsProvider,\n token,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.auto.link.${owner}.${repo}`,\n fn: async () => {\n await client.rest.repos.createAutolink({\n owner,\n repo,\n key_prefix: keyPrefix,\n url_template: urlTemplate,\n is_alphanumeric: isAlphanumeric,\n });\n\n ctx.logger.info(`Autolink reference created successfully`);\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAiCO,SAAS,4BAA4B,OAAA,EAIzC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA2B,yBAAA,EAA0B,GACzE,OAAA;AAEF,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EAAa,+CAAA;AAAA,cACbC,iCAAA;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;AA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AAA,CAAW;AAAA,QACnB,GAAA,EAAK,CAAA,iBAAA,EAAoB,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QACtC,IAAI,YAAY;AACd,UAAA,MAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAe;AAAA,YACrC,KAAA;AAAA,YACA,IAAA;AAAA,YACA,UAAA,EAAY,SAAA;AAAA,YACZ,YAAA,EAAc,WAAA;AAAA,YACd,eAAA,EAAiB;AAAA,WAClB,CAAA;AAED,UAAA,GAAA,CAAI,MAAA,CAAO,KAAK,CAAA,uCAAA,CAAyC,CAAA;AAAA,QAC3D;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubAutolinks.cjs.js","sources":["../../src/actions/githubAutolinks.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 } 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 { examples } from './githubAutolinks.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Create an autolink reference for a repository\n * @public\n */\nexport function createGithubAutolinksAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n requireScmUserCredentials?: boolean;\n}) {\n const { integrations, githubCredentialsProvider, requireScmUserCredentials } =\n options;\n\n return createTemplateAction({\n id: 'github:autolinks:create',\n description: 'Create an autolink reference for a repository',\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 keyPrefix: z =>\n z.string({\n description:\n 'This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.',\n }),\n urlTemplate: z =>\n z.string({\n description:\n 'The URL must contain `<num>` for the reference number. `<num>` matches different characters depending on the value of isAlphanumeric.',\n }),\n isAlphanumeric: z =>\n z\n .boolean({\n description:\n '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`',\n })\n .default(true)\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const { repoUrl, keyPrefix, urlTemplate, isAlphanumeric, token } =\n ctx.input;\n\n ctx.logger.info(`Creating autolink reference for repo ${repoUrl}`);\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 requireScmUserCredentials,\n host,\n owner,\n repo,\n credentialsProvider: githubCredentialsProvider,\n token,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.auto.link.${owner}.${repo}`,\n fn: async () => {\n await client.rest.repos.createAutolink({\n owner,\n repo,\n key_prefix: keyPrefix,\n url_template: urlTemplate,\n is_alphanumeric: isAlphanumeric,\n });\n\n ctx.logger.info(`Autolink reference created successfully`);\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAiCO,SAAS,4BAA4B,OAAA,EAIzC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,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A,CAAkB;AAAA,QAC7C,YAAA;AAAA,QACA,yBAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA;AAAA,QACA,IAAA;AAAA,QACA,mBAAA,EAAqB,yBAAA;AAAA,QACrB;AAAA,OACD,CAAA;AACD,MAAA,MAAM,MAAA,GAAS,IAAIC,eAAA,CAAQ;AAAA,QACzB,GAAG,cAAA;AAAA,QACH,KAAK,GAAA,CAAI;AAAA,OACV,CAAA;AAED,MAAA,MAAM,IAAI,UAAA,CAAW;AAAA,QACnB,GAAA,EAAK,CAAA,iBAAA,EAAoB,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QACtC,IAAI,YAAY;AACd,UAAA,MAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAe;AAAA,YACrC,KAAA;AAAA,YACA,IAAA;AAAA,YACA,UAAA,EAAY,SAAA;AAAA,YACZ,YAAA,EAAc,WAAA;AAAA,YACd,eAAA,EAAiB;AAAA,WAClB,CAAA;AAED,UAAA,GAAA,CAAI,MAAA,CAAO,KAAK,CAAA,uCAAA,CAAyC,CAAA;AAAA,QAC3D;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubAutolinks.examples.cjs.js","sources":["../../src/actions/githubAutolinks.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'GitHub alphanumric autolink reference',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:autolinks:create',\n name: 'Create an autolink reference',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n keyPrefix: 'TICKET-',\n urlTemplate: 'https://example.com/TICKET?query=<num>',\n isAlphanumeric: false,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,uCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,8BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,SAAA;AAAA,YACX,WAAA,EAAa,wCAAA;AAAA,YACb,cAAA,EAAgB;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"githubAutolinks.examples.cjs.js","sources":["../../src/actions/githubAutolinks.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'GitHub alphanumric autolink reference',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:autolinks:create',\n name: 'Create an autolink reference',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n keyPrefix: 'TICKET-',\n urlTemplate: 'https://example.com/TICKET?query=<num>',\n isAlphanumeric: false,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,uCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,8BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,SAAA;AAAA,YACX,WAAA,EAAa,wCAAA;AAAA,YACb,cAAA,EAAgB;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubBranchProtection.cjs.js","sources":["../../src/actions/githubBranchProtection.ts"],"sourcesContent":["/*\n * Copyright 2024 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 } from '@backstage/errors';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { examples } from './githubBranchProtection.examples';\nimport * as inputProps from './inputProperties';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport { enableBranchProtectionOnDefaultRepoBranch } from './gitHelpers';\n\n/**\n * Creates an `github:branch-protection:create` Scaffolder action that configured Branch Protection in a Github Repository.\n *\n * @public\n */\nexport function createGithubBranchProtectionAction(options: {\n integrations: ScmIntegrationRegistry;\n requireScmUserCredentials?: boolean;\n}) {\n const { integrations, requireScmUserCredentials } = options;\n\n return createTemplateAction({\n id: 'github:branch-protection:create',\n description: 'Configures Branch Protection',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n branch: inputProps.branch,\n enforceAdmins: inputProps.protectEnforceAdmins,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n blockCreations: inputProps.blockCreations,\n token: inputProps.token,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branch,\n enforceAdmins = true,\n requiredApprovingReviewCount = 1,\n requireCodeOwnerReviews = false,\n dismissStaleReviews = false,\n bypassPullRequestAllowances,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n blockCreations,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n requireScmUserCredentials,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const defaultBranch = await ctx.checkpoint({\n key: `read.default.branch.${owner}.${repo}`,\n fn: async () => {\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\n });\n return repository.data.default_branch;\n },\n });\n\n await ctx.checkpoint({\n key: `enable.branch.protection.${owner}.${repo}`,\n fn: async () => {\n await enableBranchProtectionOnDefaultRepoBranch({\n repoName: repo,\n client,\n owner,\n logger: ctx.logger,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n defaultBranch: branch ?? defaultBranch,\n enforceAdmins,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n blockCreations,\n });\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.branch","inputProps.protectEnforceAdmins","inputProps.requiredApprovingReviewCount","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.bypassPullRequestAllowances","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.blockCreations","inputProps.token","parseRepoUrl","InputError","getOctokitOptions","Octokit","enableBranchProtectionOnDefaultRepoBranch"],"mappings":";;;;;;;;;;AAiCO,SAAS,mCAAmC,OAAA,EAGhD;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,iCAAA;AAAA,IACJ,WAAA,EAAa,8BAAA;AAAA,cACbC,wCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,SAASC,uBAAW;AAAA,QACpB,QAAQC,sBAAW;AAAA,QACnB,eAAeC,oCAAW;AAAA,QAC1B,8BAA8BC,4CAAW;AAAA,QACzC,yBAAyBC,uCAAW;AAAA,QACpC,qBAAqBC,mCAAW;AAAA,QAChC,6BAA6BC,2CAAW;AAAA,QACxC,cAAcC,4BA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;AAAA,QACH,KAAK,GAAA,CAAI;AAAA,OACV,CAAA;AAED,MAAA,MAAM,aAAA,GAAgB,MAAM,GAAA,CAAI,UAAA,CAAW;AAAA,QACzC,GAAA,EAAK,CAAA,oBAAA,EAAuB,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QACzC,IAAI,YAAY;AACd,UAAA,MAAM,UAAA,GAAa,MAAM,MAAA,CAAO,IAAA,CAAK,MAAM,GAAA,CAAI;AAAA,YAC7C,KAAA;AAAA,YACA;AAAA,WACD,CAAA;AACD,UAAA,OAAO,WAAW,IAAA,CAAK,cAAA;AAAA,QACzB;AAAA,OACD,CAAA;AAED,MAAA,MAAM,IAAI,UAAA,CAAW;AAAA,QACnB,GAAA,EAAK,CAAA,yBAAA,EAA4B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QAC9C,IAAI,YAAY;AACd,UAAA,MAAMC,oDAAA,CAA0C;AAAA,YAC9C,QAAA,EAAU,IAAA;AAAA,YACV,MAAA;AAAA,YACA,KAAA;AAAA,YACA,QAAQ,GAAA,CAAI,MAAA;AAAA,YACZ,uBAAA;AAAA,YACA,2BAAA;AAAA,YACA,4BAAA;AAAA,YACA,YAAA;AAAA,YACA,2BAAA;AAAA,YACA,2BAAA;AAAA,YACA,8BAAA;AAAA,YACA,uBAAA;AAAA,YACA,eAAe,MAAA,IAAU,aAAA;AAAA,YACzB,aAAA;AAAA,YACA,mBAAA;AAAA,YACA,qBAAA;AAAA,YACA,qBAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubBranchProtection.cjs.js","sources":["../../src/actions/githubBranchProtection.ts"],"sourcesContent":["/*\n * Copyright 2024 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 } from '@backstage/errors';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { examples } from './githubBranchProtection.examples';\nimport * as inputProps from './inputProperties';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport { enableBranchProtectionOnDefaultRepoBranch } from './gitHelpers';\n\n/**\n * Creates an `github:branch-protection:create` Scaffolder action that configured Branch Protection in a Github Repository.\n *\n * @public\n */\nexport function createGithubBranchProtectionAction(options: {\n integrations: ScmIntegrationRegistry;\n requireScmUserCredentials?: boolean;\n}) {\n const { integrations, requireScmUserCredentials } = options;\n\n return createTemplateAction({\n id: 'github:branch-protection:create',\n description: 'Configures Branch Protection',\n examples,\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n branch: inputProps.branch,\n enforceAdmins: inputProps.protectEnforceAdmins,\n requiredApprovingReviewCount: inputProps.requiredApprovingReviewCount,\n requireCodeOwnerReviews: inputProps.requireCodeOwnerReviews,\n dismissStaleReviews: inputProps.dismissStaleReviews,\n bypassPullRequestAllowances: inputProps.bypassPullRequestAllowances,\n restrictions: inputProps.restrictions,\n requiredStatusCheckContexts: inputProps.requiredStatusCheckContexts,\n requireBranchesToBeUpToDate: inputProps.requireBranchesToBeUpToDate,\n requiredConversationResolution:\n inputProps.requiredConversationResolution,\n requireLastPushApproval: inputProps.requireLastPushApproval,\n requiredCommitSigning: inputProps.requiredCommitSigning,\n requiredLinearHistory: inputProps.requiredLinearHistory,\n blockCreations: inputProps.blockCreations,\n token: inputProps.token,\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branch,\n enforceAdmins = true,\n requiredApprovingReviewCount = 1,\n requireCodeOwnerReviews = false,\n dismissStaleReviews = false,\n bypassPullRequestAllowances,\n restrictions,\n requiredStatusCheckContexts = [],\n requireBranchesToBeUpToDate = true,\n requiredConversationResolution = false,\n requireLastPushApproval = false,\n requiredCommitSigning = false,\n requiredLinearHistory = false,\n blockCreations,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n requireScmUserCredentials,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const defaultBranch = await ctx.checkpoint({\n key: `read.default.branch.${owner}.${repo}`,\n fn: async () => {\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\n });\n return repository.data.default_branch;\n },\n });\n\n await ctx.checkpoint({\n key: `enable.branch.protection.${owner}.${repo}`,\n fn: async () => {\n await enableBranchProtectionOnDefaultRepoBranch({\n repoName: repo,\n client,\n owner,\n logger: ctx.logger,\n requireCodeOwnerReviews,\n bypassPullRequestAllowances,\n requiredApprovingReviewCount,\n restrictions,\n requiredStatusCheckContexts,\n requireBranchesToBeUpToDate,\n requiredConversationResolution,\n requireLastPushApproval,\n defaultBranch: branch ?? defaultBranch,\n enforceAdmins,\n dismissStaleReviews,\n requiredCommitSigning,\n requiredLinearHistory,\n blockCreations,\n });\n },\n });\n },\n });\n}\n"],"names":["createTemplateAction","examples","inputProps.repoUrl","inputProps.branch","inputProps.protectEnforceAdmins","inputProps.requiredApprovingReviewCount","inputProps.requireCodeOwnerReviews","inputProps.dismissStaleReviews","inputProps.bypassPullRequestAllowances","inputProps.restrictions","inputProps.requiredStatusCheckContexts","inputProps.requireBranchesToBeUpToDate","inputProps.requiredConversationResolution","inputProps.requireLastPushApproval","inputProps.requiredCommitSigning","inputProps.requiredLinearHistory","inputProps.blockCreations","inputProps.token","parseRepoU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I,MAAA;AAAA,YACZ,uBAAA;AAAA,YACA,2BAAA;AAAA,YACA,4BAAA;AAAA,YACA,YAAA;AAAA,YACA,2BAAA;AAAA,YACA,2BAAA;AAAA,YACA,8BAAA;AAAA,YACA,uBAAA;AAAA,YACA,eAAe,MAAA,IAAU,aAAA;AAAA,YACzB,aAAA;AAAA,YACA,mBAAA;AAAA,YACA,qBAAA;AAAA,YACA,qBAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACD,CAAA;AACH;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubBranchProtection.examples.cjs.js","sources":["../../src/actions/githubBranchProtection.examples.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: `GitHub Branch Protection for repository's default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection for a specific branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branch: 'my-awesome-branch',\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection and required commit signing on default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n requireCodeOwnerReviews: true,\n requiredStatusCheckContexts: ['test'],\n dismissStaleReviews: true,\n requireLastPushApproval: true,\n requiredConversationResolution: true,\n requiredCommitSigning: true,\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection and required linear history on default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n requireCodeOwnerReviews: true,\n requiredStatusCheckContexts: ['test'],\n dismissStaleReviews: true,\n requireLastPushApproval: true,\n requiredConversationResolution: true,\n requiredCommitSigning: true,\n requiredLinearHistory: true,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,CAAA,yDAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,CAAA,+CAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,MAAA,EAAQ;AAAA;AACV;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,CAAA,uEAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,uBAAA,EAAyB,IAAA;AAAA,YACzB,2BAAA,EAA6B,CAAC,MAAM,CAAA;AAAA,YACpC,mBAAA,EAAqB,IAAA;AAAA,YACrB,uBAAA,EAAyB,IAAA;AAAA,YACzB,8BAAA,EAAgC,IAAA;AAAA,YAChC,qBAAA,EAAuB;AAAA;AACzB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,CAAA,uEAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,uBAAA,EAAyB,IAAA;AAAA,YACzB,2BAAA,EAA6B,CAAC,MAAM,CAAA;AAAA,YACpC,mBAAA,EAAqB,IAAA;AAAA,YACrB,uBAAA,EAAyB,IAAA;AAAA,YACzB,8BAAA,EAAgC,IAAA;AAAA,YAChC,qBAAA,EAAuB,IAAA;AAAA,YACvB,qBAAA,EAAuB;AAAA;AACzB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"githubBranchProtection.examples.cjs.js","sources":["../../src/actions/githubBranchProtection.examples.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: `GitHub Branch Protection for repository's default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection for a specific branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n branch: 'my-awesome-branch',\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection and required commit signing on default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n requireCodeOwnerReviews: true,\n requiredStatusCheckContexts: ['test'],\n dismissStaleReviews: true,\n requireLastPushApproval: true,\n requiredConversationResolution: true,\n requiredCommitSigning: true,\n },\n },\n ],\n }),\n },\n {\n description: `GitHub Branch Protection and required linear history on default branch.`,\n example: yaml.stringify({\n steps: [\n {\n action: 'github:branch-protection:create',\n name: 'Setup Branch Protection',\n input: {\n repoUrl: 'github.com?repo=repo&owner=owner',\n requireCodeOwnerReviews: true,\n requiredStatusCheckContexts: ['test'],\n dismissStaleReviews: true,\n requireLastPushApproval: true,\n requiredConversationResolution: true,\n requiredCommitSigning: true,\n requiredLinearHistory: true,\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,CAAA,yDAAA,CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,iCAAA;AAAA,UACR,IAAA,EAAM,yBAAA;A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BAAA,EAAyB,IAAA;AAAA,YACzB,8BAAA,EAAgC,IAAA;AAAA,YAChC,qBAAA,EAAuB,IAAA;AAAA,YACvB,qBAAA,EAAuB;AAAA;AACzB;AACF;AACF,KACD;AAAA;AAEL;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubDeployKey.cjs.js","sources":["../../src/actions/githubDeployKey.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 } from '@backstage/errors';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport Sodium from 'libsodium-wrappers';\nimport { examples } from './githubDeployKey.examples';\n\n/**\n * Creates an `github:deployKey:create` Scaffolder action that creates a Deploy Key\n *\n * @public\n */\nexport function createGithubDeployKeyAction(options: {\n integrations: ScmIntegrationRegistry;\n requireScmUserCredentials?: boolean;\n}) {\n const { integrations, requireScmUserCredentials } = options;\n // For more information on how to define custom actions, see\n // https://backstage.io/docs/features/software-templates/writing-custom-actions\n return createTemplateAction({\n id: 'github:deployKey:create',\n description: 'Creates and stores Deploy Keys',\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 publicKey: z =>\n z.string({\n description:\n '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`.',\n }),\n privateKey: z =>\n z.string({\n description: 'SSH Private Key generated from `ssh-keygen`',\n }),\n deployKeyName: z =>\n z.string({\n description: `Name of the Deploy Key`,\n }),\n privateKeySecretName: z =>\n z\n .string({\n description:\n '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',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n },\n output: {\n privateKeySecretName: z =>\n z.string({\n description:\n 'The GitHub Action Repo Secret Name for the Private Key',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n publicKey,\n privateKey,\n deployKeyName,\n privateKeySecretName = `${deployKeyName\n .split(' ')\n .join('_')\n .toUpperCase()}_PRIVATE_KEY`,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n requireScmUserCredentials,\n token: providedToken,\n host,\n owner,\n repo,\n });\n\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.deploy.key.${owner}.${repo}.${publicKey}`,\n fn: async () => {\n await client.rest.repos.createDeployKey({\n owner: owner,\n repo: repo,\n title: deployKeyName,\n key: publicKey,\n });\n },\n });\n\n const { key, keyId } = await ctx.checkpoint({\n key: `get.repo.public.key.${owner}.${repo}`,\n fn: async () => {\n const publicKeyResponse = await client.rest.actions.getRepoPublicKey({\n owner: owner,\n repo: repo,\n });\n return {\n key: publicKeyResponse.data.key,\n keyId: publicKeyResponse.data.key_id,\n };\n },\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n key,\n Sodium.base64_variants.ORIGINAL,\n );\n const binarySecret = Sodium.from_string(privateKey);\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 ctx.checkpoint({\n key: `create.or.update.repo.secret.${owner}.${repo}.${keyId}`,\n fn: async () => {\n await client.rest.actions.createOrUpdateRepoSecret({\n owner: owner,\n repo: repo,\n secret_name: privateKeySecretName,\n encrypted_value: encryptedBase64Secret,\n key_id: keyId,\n });\n },\n });\n\n ctx.output('privateKeySecretName', privateKeySecretName);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAgCO,SAAS,4BAA4B,OAAA,EAGzC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAGpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EAAa,gCAAA;AAAA,cACbC,iCAAA;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,SAAA,EAAW,CAAA,CAAA,KACT,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,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sBAAA;AAAA,SACd,CAAA;AAAA,QACH,oBAAA,EAAsB,CAAA,CAAA,KACpB,CAAA,CACG,MAAA,CAAO;AAAA,U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I,KAAK,CAAA,CAAA;AAAA,QAC3D,IAAI,YAAY;AACd,UAAA,MAAM,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,wBAAA,CAAyB;AAAA,YACjD,KAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAA,EAAa,oBAAA;AAAA,YACb,eAAA,EAAiB,qBAAA;AAAA,YACjB,MAAA,EAAQ;AAAA,WACT,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,wBAAwB,oBAAoB,CAAA;AAAA,IACzD;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubDeployKey.cjs.js","sources":["../../src/actions/githubDeployKey.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 } from '@backstage/errors';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport Sodium from 'libsodium-wrappers';\nimport { examples } from './githubDeployKey.examples';\n\n/**\n * Creates an `github:deployKey:create` Scaffolder action that creates a Deploy Key\n *\n * @public\n */\nexport function createGithubDeployKeyAction(options: {\n integrations: ScmIntegrationRegistry;\n requireScmUserCredentials?: boolean;\n}) {\n const { integrations, requireScmUserCredentials } = options;\n // For more information on how to define custom actions, see\n // https://backstage.io/docs/features/software-templates/writing-custom-actions\n return createTemplateAction({\n id: 'github:deployKey:create',\n description: 'Creates and stores Deploy Keys',\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 publicKey: z =>\n z.string({\n description:\n '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`.',\n }),\n privateKey: z =>\n z.string({\n description: 'SSH Private Key generated from `ssh-keygen`',\n }),\n deployKeyName: z =>\n z.string({\n description: `Name of the Deploy Key`,\n }),\n privateKeySecretName: z =>\n z\n .string({\n description:\n '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',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n },\n output: {\n privateKeySecretName: z =>\n z.string({\n description:\n 'The GitHub Action Repo Secret Name for the Private Key',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n publicKey,\n privateKey,\n deployKeyName,\n privateKeySecretName = `${deployKeyName\n .split(' ')\n .join('_')\n .toUpperCase()}_PRIVATE_KEY`,\n token: providedToken,\n } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n requireScmUserCredentials,\n token: providedToken,\n host,\n owner,\n repo,\n });\n\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n await ctx.checkpoint({\n key: `create.deploy.key.${owner}.${repo}.${publicKey}`,\n fn: async () => {\n await client.rest.repos.createDeployKey({\n owner: owner,\n repo: repo,\n title: deployKeyName,\n key: publicKey,\n });\n },\n });\n\n const { key, keyId } = await ctx.checkpoint({\n key: `get.repo.public.key.${owner}.${repo}`,\n fn: async () => {\n const publicKeyResponse = await client.rest.actions.getRepoPublicKey({\n owner: owner,\n repo: repo,\n });\n return {\n key: publicKeyResponse.data.key,\n keyId: publicKeyResponse.data.key_id,\n };\n },\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n key,\n Sodium.base64_variants.ORIGINAL,\n );\n const binarySecret = Sodium.from_string(privateKey);\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 ctx.checkpoint({\n key: `create.or.update.repo.secret.${owner}.${repo}.${keyId}`,\n fn: async () => {\n await client.rest.actions.createOrUpdateRepoSecret({\n owner: owner,\n repo: repo,\n secret_name: privateKeySecretName,\n encrypted_value: encryptedBase64Secret,\n key_id: keyId,\n });\n },\n });\n\n ctx.output('privateKeySecretName', privateKeySecretName);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAgCO,SAAS,4BAA4B,OAAA,EAGzC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAGpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EAAa,gCAAA;AAAA,cACbC,iCAAA;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,SAAA,EAAW,CAAA,CAAA,KACT,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,E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AAA,MAAM,wBAAwBA,uBAAA,CAAO,SAAA;AAAA,QACnC,qBAAA;AAAA,QACAA,wBAAO,eAAA,CAAgB;AAAA,OACzB;AAEA,MAAA,MAAM,IAAI,UAAA,CAAW;AAAA,QACnB,KAAK,CAAA,6BAAA,EAAgC,KAAK,CAAA,CAAA,EAAI,IAAI,IAAI,KAAK,CAAA,CAAA;AAAA,QAC3D,IAAI,YAAY;AACd,UAAA,MAAM,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,wBAAA,CAAyB;AAAA,YACjD,KAAA;AAAA,YACA,IAAA;AAAA,YACA,WAAA,EAAa,oBAAA;AAAA,YACb,eAAA,EAAiB,qBAAA;AAAA,YACjB,MAAA,EAAQ;AAAA,WACT,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,wBAAwB,oBAAoB,CAAA;AAAA,IACzD;AAAA,GACD,CAAA;AACH;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubDeployKey.examples.cjs.js","sources":["../../src/actions/githubDeployKey.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Example 1: Create and store a Deploy Key',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:deployKey:create',\n name: 'Create and store a Deploy Key',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n publicKey: 'pubkey',\n privateKey: 'privkey',\n deployKeyName: 'Push Tags',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,0CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,+BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,SAAA,EAAW,QAAA;AAAA,YACX,UAAA,EAAY,SAAA;AAAA,YACZ,aAAA,EAAe;AAAA;AACjB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"githubDeployKey.examples.cjs.js","sources":["../../src/actions/githubDeployKey.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Example 1: Create and store a Deploy Key',\n example: yaml.stringify({\n steps: [\n {\n action: 'github:deployKey:create',\n name: 'Create and store a Deploy Key',\n input: {\n repoUrl: 'github.com?repo=repository&owner=owner',\n publicKey: 'pubkey',\n privateKey: 'privkey',\n deployKeyName: 'Push Tags',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,0CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,IAAA,EAAM,+BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,wCAAA;AAAA,YACT,SAAA,EAAW,QAAA;AAAA,YACX,UAAA,EAAY,SAAA;AAAA,YACZ,aAAA,EAAe;AAAA;AACjB;AACF;AACF,KACD;AAAA;AAEL;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"githubEnvironment.cjs.js","sources":["../../src/actions/githubEnvironment.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 } from '@backstage/errors';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport Sodium from 'libsodium-wrappers';\nimport { examples } from './gitHubEnvironment.examples';\nimport { Entity } from '@backstage/catalog-model';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\n/**\n * Creates an `github:environment:create` Scaffolder action that creates a Github Environment.\n *\n * @public\n */\nexport function createGithubEnvironmentAction(options: {\n integrations: ScmIntegrationRegistry;\n catalog: CatalogService;\n requireScmUserCredentials?: boolean;\n}) {\n const { integrations, catalog, requireScmUserCredentials } = options;\n // For more information on how to define custom actions, see\n // https://backstage.io/docs/features/software-templates/writing-custom-actions\n return createTemplateAction({\n id: 'github:environment:create',\n description: 'Creates Deployment Environments',\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 name: z =>\n z.string({\n description: `Name of the deployment environment to create`,\n }),\n deploymentBranchPolicy: z =>\n z\n .object(\n {\n protected_branches: z.boolean({\n description:\n '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`.',\n }),\n custom_branch_policies: z.boolean({\n description:\n '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`.',\n }),\n },\n {\n description:\n 'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',\n },\n )\n .optional(),\n customBranchPolicyNames: z =>\n z\n .array(z.string(), {\n description: `The name pattern that branches must match in order to deploy to the environment.\n\nWildcard 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.`,\n })\n .optional(),\n customTagPolicyNames: z =>\n z\n .array(z.string(), {\n description: `The name pattern that tags must match in order to deploy to the environment.\n\nWildcard 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.`,\n })\n .optional(),\n environmentVariables: z =>\n z\n .record(z.string(), {\n description: `Environment variables attached to the deployment environment`,\n })\n .optional(),\n secrets: z =>\n z\n .record(z.string(), {\n description: `Secrets attached to the deployment environment`,\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n waitTimer: z =>\n z\n .number({\n description:\n 'The time to wait before creating or updating the environment (in minutes)',\n })\n .optional(),\n preventSelfReview: z =>\n z\n .boolean({\n description:\n 'Whether to prevent self-review for this environment',\n })\n .optional(),\n reviewers: z =>\n z\n .array(z.string(), {\n description:\n 'Reviewers for this environment. Must be a list of Backstage entity references.',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n name,\n deploymentBranchPolicy,\n customBranchPolicyNames,\n customTagPolicyNames,\n environmentVariables,\n secrets,\n token: providedToken,\n waitTimer,\n preventSelfReview,\n reviewers,\n } = ctx.input;\n\n // When environment creation step is executed right after a repo publish step, the repository might not be available immediately.\n // Add a 2-second delay before initiating the steps in this action.\n await new Promise(resolve => setTimeout(resolve, 2000));\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n requireScmUserCredentials,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const repositoryId = await ctx.checkpoint({\n key: `get.repo.${owner}.${repo}`,\n fn: async () => {\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\n });\n return repository.data.id;\n },\n });\n\n // convert reviewers from catalog entity to Github user or team\n const githubReviewers: { type: 'User' | 'Team'; id: number }[] = [];\n if (reviewers) {\n let reviewersEntityRefs: Array<Entity | undefined> = [];\n // Fetch reviewers from Catalog\n const catalogResponse = await catalog.getEntitiesByRefs(\n {\n entityRefs: reviewers,\n },\n {\n credentials: await ctx.getInitiatorCredentials(),\n },\n );\n if (catalogResponse?.items?.length) {\n reviewersEntityRefs = catalogResponse.items;\n }\n\n for (const reviewerEntityRef of reviewersEntityRefs) {\n if (reviewerEntityRef?.kind === 'User') {\n try {\n const userId = await ctx.checkpoint({\n key: `get.user.${reviewerEntityRef.metadata.name}`,\n fn: async () => {\n const user = await client.rest.users.getByUsername({\n username: reviewerEntityRef.metadata.name,\n });\n return user.data.id;\n },\n });\n\n githubReviewers.push({\n type: 'User',\n id: userId,\n });\n } catch (error) {\n ctx.logger.error('User not found:', error);\n }\n } else if (reviewerEntityRef?.kind === 'Group') {\n try {\n const teamId = await ctx.checkpoint({\n key: `get.team.${reviewerEntityRef.metadata.name}`,\n fn: async () => {\n const team = await client.rest.teams.getByName({\n org: owner,\n team_slug: reviewerEntityRef.metadata.name,\n });\n return team.data.id;\n },\n });\n\n githubReviewers.push({\n type: 'Team',\n id: teamId,\n });\n } catch (error) {\n ctx.logger.error('Team not found:', error);\n }\n }\n }\n }\n\n await ctx.checkpoint({\n key: `create.or.update.environment.${owner}.${repo}.${name}`,\n fn: async () => {\n await client.rest.repos.createOrUpdateEnvironment({\n owner: owner,\n repo: repo,\n environment_name: name,\n deployment_branch_policy: deploymentBranchPolicy ?? undefined,\n wait_timer: waitTimer ?? undefined,\n prevent_self_review: preventSelfReview ?? undefined,\n reviewers: githubReviewers.length ? githubReviewers : undefined,\n });\n },\n });\n\n if (customBranchPolicyNames) {\n for (const item of customBranchPolicyNames) {\n await ctx.checkpoint({\n key: `create.deployment.branch.policy.branch.${owner}.${repo}.${name}.${item}`,\n fn: async () => {\n await client.rest.repos.createDeploymentBranchPolicy({\n owner: owner,\n repo: repo,\n type: 'branch',\n environment_name: name,\n name: item,\n });\n },\n });\n }\n }\n\n if (customTagPolicyNames) {\n for (const item of customTagPolicyNames) {\n await ctx.checkpoint({\n key: `create.deployment.branch.policy.tag.${owner}.${repo}.${name}.${item}`,\n fn: async () => {\n await client.rest.repos.createDeploymentBranchPolicy({\n owner: owner,\n repo: repo,\n type: 'tag',\n environment_name: name,\n name: item,\n });\n },\n });\n }\n }\n\n for (const [key, value] of Object.entries(environmentVariables ?? {})) {\n await ctx.checkpoint({\n key: `create.env.variable.${owner}.${repo}.${name}.${key}`,\n fn: async () => {\n await client.rest.actions.createEnvironmentVariable({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n name: key,\n value,\n });\n },\n });\n }\n\n if (secrets) {\n const { publicKey, publicKeyId } = await ctx.checkpoint({\n key: `get.env.public.key.${owner}.${repo}.${name}`,\n fn: async () => {\n const publicKeyResponse =\n await client.rest.actions.getEnvironmentPublicKey({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n });\n return {\n publicKey: publicKeyResponse.data.key,\n publicKeyId: publicKeyResponse.data.key_id,\n };\n },\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKey,\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 ctx.checkpoint({\n key: `create.or.update.env.secret.${owner}.${repo}.${name}.${key}`,\n fn: async () => {\n await client.rest.actions.createOrUpdateEnvironmentSecret({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n secret_name: key,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyId,\n });\n },\n });\n }\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAkCO,SAAS,8BAA8B,OAAA,EAI3C;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,OAAA,EAAS,yBAAA,EAA0B,GAAI,OAAA;AAG7D,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,2BAAA;AAAA,IACJ,WAAA,EAAa,iCAAA;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,IAAA,EAAM,CAAA,CAAA,KACJ,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,4CAAA;AAAA,SACd,CAAA;AAAA,QACH,sBAAA,EAAwB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,YAAA,GAAeA,uBAAA,CAAO,WAAA,CAAY,KAAK,CAAA;AAC7C,UAAA,MAAM,wBAAwBA,uBAAA,CAAO,eAAA;AAAA,YACnC,YAAA;AAAA,YACA;AAAA,WACF;AACA,UAAA,MAAM,wBAAwBA,uBAAA,CAAO,SAAA;AAAA,YACnC,qBAAA;AAAA,YACAA,wBAAO,eAAA,CAAgB;AAAA,WACzB;AAEA,UAAA,MAAM,IAAI,UAAA,CAAW;AAAA,YACnB,GAAA,EAAK,+BAA+B,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA,EAAI,IAAI,IAAI,GAAG,CAAA,CAAA;AAAA,YAChE,IAAI,YAAY;AACd,cAAA,MAAM,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,+BAAA,CAAgC;AAAA,gBACxD,aAAA,EAAe,YAAA;AAAA,gBACf,KAAA;AAAA,gBACA,IAAA;AAAA,gBACA,gBAAA,EAAkB,IAAA;AAAA,gBAClB,WAAA,EAAa,GAAA;AAAA,gBACb,eAAA,EAAiB,qBAAA;AAAA,gBACjB,MAAA,EAAQ;AAAA,eACT,CAAA;AAAA,YACH;AAAA,WACD,CAAA;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubEnvironment.cjs.js","sources":["../../src/actions/githubEnvironment.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 } from '@backstage/errors';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getOctokitOptions } from '../util';\nimport { Octokit } from 'octokit';\nimport Sodium from 'libsodium-wrappers';\nimport { examples } from './gitHubEnvironment.examples';\nimport { Entity } from '@backstage/catalog-model';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\n/**\n * Creates an `github:environment:create` Scaffolder action that creates a Github Environment.\n *\n * @public\n */\nexport function createGithubEnvironmentAction(options: {\n integrations: ScmIntegrationRegistry;\n catalog: CatalogService;\n requireScmUserCredentials?: boolean;\n}) {\n const { integrations, catalog, requireScmUserCredentials } = options;\n // For more information on how to define custom actions, see\n // https://backstage.io/docs/features/software-templates/writing-custom-actions\n return createTemplateAction({\n id: 'github:environment:create',\n description: 'Creates Deployment Environments',\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 name: z =>\n z.string({\n description: `Name of the deployment environment to create`,\n }),\n deploymentBranchPolicy: z =>\n z\n .object(\n {\n protected_branches: z.boolean({\n description:\n '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`.',\n }),\n custom_branch_policies: z.boolean({\n description:\n '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`.',\n }),\n },\n {\n description:\n 'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',\n },\n )\n .optional(),\n customBranchPolicyNames: z =>\n z\n .array(z.string(), {\n description: `The name pattern that branches must match in order to deploy to the environment.\n\nWildcard 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.`,\n })\n .optional(),\n customTagPolicyNames: z =>\n z\n .array(z.string(), {\n description: `The name pattern that tags must match in order to deploy to the environment.\n\nWildcard 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.`,\n })\n .optional(),\n environmentVariables: z =>\n z\n .record(z.string(), {\n description: `Environment variables attached to the deployment environment`,\n })\n .optional(),\n secrets: z =>\n z\n .record(z.string(), {\n description: `Secrets attached to the deployment environment`,\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitHub',\n })\n .optional(),\n waitTimer: z =>\n z\n .number({\n description:\n 'The time to wait before creating or updating the environment (in minutes)',\n })\n .optional(),\n preventSelfReview: z =>\n z\n .boolean({\n description:\n 'Whether to prevent self-review for this environment',\n })\n .optional(),\n reviewers: z =>\n z\n .array(z.string(), {\n description:\n 'Reviewers for this environment. Must be a list of Backstage entity references.',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n name,\n deploymentBranchPolicy,\n customBranchPolicyNames,\n customTagPolicyNames,\n environmentVariables,\n secrets,\n token: providedToken,\n waitTimer,\n preventSelfReview,\n reviewers,\n } = ctx.input;\n\n // When environment creation step is executed right after a repo publish step, the repository might not be available immediately.\n // Add a 2-second delay before initiating the steps in this action.\n await new Promise(resolve => setTimeout(resolve, 2000));\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(`No owner provided for repo ${repoUrl}`);\n }\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n requireScmUserCredentials,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit({\n ...octokitOptions,\n log: ctx.logger,\n });\n\n const repositoryId = await ctx.checkpoint({\n key: `get.repo.${owner}.${repo}`,\n fn: async () => {\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\n });\n return repository.data.id;\n },\n });\n\n // convert reviewers from catalog entity to Github user or team\n const githubReviewers: { type: 'User' | 'Team'; id: number }[] = [];\n if (reviewers) {\n let reviewersEntityRefs: Array<Entity | undefined> = [];\n // Fetch reviewers from Catalog\n const catalogResponse = await catalog.getEntitiesByRefs(\n {\n entityRefs: reviewers,\n },\n {\n credentials: await ctx.getInitiatorCredentials(),\n },\n );\n if (catalogResponse?.items?.length) {\n reviewersEntityRefs = catalogResponse.items;\n }\n\n for (const reviewerEntityRef of reviewersEntityRefs) {\n if (reviewerEntityRef?.kind === 'User') {\n try {\n const userId = await ctx.checkpoint({\n key: `get.user.${reviewerEntityRef.metadata.name}`,\n fn: async () => {\n const user = await client.rest.users.getByUsername({\n username: reviewerEntityRef.metadata.name,\n });\n return user.data.id;\n },\n });\n\n githubReviewers.push({\n type: 'User',\n id: userId,\n });\n } catch (error) {\n ctx.logger.error('User not found:', error);\n }\n } else if (reviewerEntityRef?.kind === 'Group') {\n try {\n const teamId = await ctx.checkpoint({\n key: `get.team.${reviewerEntityRef.metadata.name}`,\n fn: async () => {\n const team = await client.rest.teams.getByName({\n org: owner,\n team_slug: reviewerEntityRef.metadata.name,\n });\n return team.data.id;\n },\n });\n\n githubReviewers.push({\n type: 'Team',\n id: teamId,\n });\n } catch (error) {\n ctx.logger.error('Team not found:', error);\n }\n }\n }\n }\n\n await ctx.checkpoint({\n key: `create.or.update.environment.${owner}.${repo}.${name}`,\n fn: async () => {\n await client.rest.repos.createOrUpdateEnvironment({\n owner: owner,\n repo: repo,\n environment_name: name,\n deployment_branch_policy: deploymentBranchPolicy ?? undefined,\n wait_timer: waitTimer ?? undefined,\n prevent_self_review: preventSelfReview ?? undefined,\n reviewers: githubReviewers.length ? githubReviewers : undefined,\n });\n },\n });\n\n if (customBranchPolicyNames) {\n for (const item of customBranchPolicyNames) {\n await ctx.checkpoint({\n key: `create.deployment.branch.policy.branch.${owner}.${repo}.${name}.${item}`,\n fn: async () => {\n await client.rest.repos.createDeploymentBranchPolicy({\n owner: owner,\n repo: repo,\n type: 'branch',\n environment_name: name,\n name: item,\n });\n },\n });\n }\n }\n\n if (customTagPolicyNames) {\n for (const item of customTagPolicyNames) {\n await ctx.checkpoint({\n key: `create.deployment.branch.policy.tag.${owner}.${repo}.${name}.${item}`,\n fn: async () => {\n await client.rest.repos.createDeploymentBranchPolicy({\n owner: owner,\n repo: repo,\n type: 'tag',\n environment_name: name,\n name: item,\n });\n },\n });\n }\n }\n\n for (const [key, value] of Object.entries(environmentVariables ?? {})) {\n await ctx.checkpoint({\n key: `create.env.variable.${owner}.${repo}.${name}.${key}`,\n fn: async () => {\n await client.rest.actions.createEnvironmentVariable({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n name: key,\n value,\n });\n },\n });\n }\n\n if (secrets) {\n const { publicKey, publicKeyId } = await ctx.checkpoint({\n key: `get.env.public.key.${owner}.${repo}.${name}`,\n fn: async () => {\n const publicKeyResponse =\n await client.rest.actions.getEnvironmentPublicKey({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n });\n return {\n publicKey: publicKeyResponse.data.key,\n publicKeyId: publicKeyResponse.data.key_id,\n };\n },\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKey,\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 ctx.checkpoint({\n key: `create.or.update.env.secret.${owner}.${repo}.${name}.${key}`,\n fn: async () => {\n await client.rest.actions.createOrUpdateEnvironmentSecret({\n repository_id: repositoryId,\n owner: owner,\n repo: repo,\n environment_name: name,\n secret_name: key,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyId,\n });\n },\n });\n }\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAkCO,SAAS,8BAA8B,O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