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

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 (63) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/actions/gitHelpers.cjs.js +90 -0
  3. package/dist/actions/gitHelpers.cjs.js.map +1 -0
  4. package/dist/actions/gitHubEnvironment.examples.cjs.js +340 -0
  5. package/dist/actions/gitHubEnvironment.examples.cjs.js.map +1 -0
  6. package/dist/actions/github.cjs.js +187 -0
  7. package/dist/actions/github.cjs.js.map +1 -0
  8. package/dist/actions/github.examples.cjs.js +60 -0
  9. package/dist/actions/github.examples.cjs.js.map +1 -0
  10. package/dist/actions/githubActionsDispatch.cjs.js +84 -0
  11. package/dist/actions/githubActionsDispatch.cjs.js.map +1 -0
  12. package/dist/actions/githubActionsDispatch.examples.cjs.js +66 -0
  13. package/dist/actions/githubActionsDispatch.examples.cjs.js.map +1 -0
  14. package/dist/actions/githubAutolinks.cjs.js +76 -0
  15. package/dist/actions/githubAutolinks.cjs.js.map +1 -0
  16. package/dist/actions/githubAutolinks.examples.cjs.js +30 -0
  17. package/dist/actions/githubAutolinks.examples.cjs.js.map +1 -0
  18. package/dist/actions/githubBranchProtection.cjs.js +97 -0
  19. package/dist/actions/githubBranchProtection.cjs.js.map +1 -0
  20. package/dist/actions/githubBranchProtection.examples.cjs.js +62 -0
  21. package/dist/actions/githubBranchProtection.examples.cjs.js.map +1 -0
  22. package/dist/actions/githubDeployKey.cjs.js +123 -0
  23. package/dist/actions/githubDeployKey.cjs.js.map +1 -0
  24. package/dist/actions/githubDeployKey.examples.cjs.js +30 -0
  25. package/dist/actions/githubDeployKey.examples.cjs.js.map +1 -0
  26. package/dist/actions/githubEnvironment.cjs.js +255 -0
  27. package/dist/actions/githubEnvironment.cjs.js.map +1 -0
  28. package/dist/actions/githubIssuesLabel.cjs.js +79 -0
  29. package/dist/actions/githubIssuesLabel.cjs.js.map +1 -0
  30. package/dist/actions/githubIssuesLabel.examples.cjs.js +46 -0
  31. package/dist/actions/githubIssuesLabel.examples.cjs.js.map +1 -0
  32. package/dist/actions/githubPagesEnable.cjs.js +88 -0
  33. package/dist/actions/githubPagesEnable.cjs.js.map +1 -0
  34. package/dist/actions/githubPagesEnable.examples.cjs.js +224 -0
  35. package/dist/actions/githubPagesEnable.examples.cjs.js.map +1 -0
  36. package/dist/actions/githubPullRequest.cjs.js +336 -0
  37. package/dist/actions/githubPullRequest.cjs.js.map +1 -0
  38. package/dist/actions/githubPullRequest.examples.cjs.js +260 -0
  39. package/dist/actions/githubPullRequest.examples.cjs.js.map +1 -0
  40. package/dist/actions/githubRepoCreate.cjs.js +130 -0
  41. package/dist/actions/githubRepoCreate.cjs.js.map +1 -0
  42. package/dist/actions/githubRepoCreate.examples.cjs.js +964 -0
  43. package/dist/actions/githubRepoCreate.examples.cjs.js.map +1 -0
  44. package/dist/actions/githubRepoPush.cjs.js +122 -0
  45. package/dist/actions/githubRepoPush.cjs.js.map +1 -0
  46. package/dist/actions/githubRepoPush.examples.cjs.js +57 -0
  47. package/dist/actions/githubRepoPush.examples.cjs.js.map +1 -0
  48. package/dist/actions/githubWebhook.cjs.js +135 -0
  49. package/dist/actions/githubWebhook.cjs.js.map +1 -0
  50. package/dist/actions/githubWebhook.examples.cjs.js +113 -0
  51. package/dist/actions/githubWebhook.examples.cjs.js.map +1 -0
  52. package/dist/actions/helpers.cjs.js +292 -0
  53. package/dist/actions/helpers.cjs.js.map +1 -0
  54. package/dist/actions/inputProperties.cjs.js +319 -0
  55. package/dist/actions/inputProperties.cjs.js.map +1 -0
  56. package/dist/actions/outputProperties.cjs.js +19 -0
  57. package/dist/actions/outputProperties.cjs.js.map +1 -0
  58. package/dist/index.cjs.js +31 -4306
  59. package/dist/index.cjs.js.map +1 -1
  60. package/dist/index.d.ts +33 -1
  61. package/dist/module.cjs.js +92 -0
  62. package/dist/module.cjs.js.map +1 -0
  63. package/package.json +11 -11
@@ -0,0 +1,187 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+ var octokit = require('octokit');
5
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
6
+ var helpers = require('./helpers.cjs.js');
7
+ var inputProperties = require('./inputProperties.cjs.js');
8
+ var outputProperties = require('./outputProperties.cjs.js');
9
+ var github_examples = require('./github.examples.cjs.js');
10
+
11
+ function createPublishGithubAction(options) {
12
+ const { integrations, config, githubCredentialsProvider } = options;
13
+ return pluginScaffolderNode.createTemplateAction({
14
+ id: "publish:github",
15
+ description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
16
+ examples: github_examples.examples,
17
+ schema: {
18
+ input: {
19
+ type: "object",
20
+ required: ["repoUrl"],
21
+ properties: {
22
+ repoUrl: inputProperties.repoUrl,
23
+ description: inputProperties.description,
24
+ homepage: inputProperties.homepage,
25
+ access: inputProperties.access,
26
+ bypassPullRequestAllowances: inputProperties.bypassPullRequestAllowances,
27
+ requiredApprovingReviewCount: inputProperties.requiredApprovingReviewCount,
28
+ restrictions: inputProperties.restrictions,
29
+ requireCodeOwnerReviews: inputProperties.requireCodeOwnerReviews,
30
+ dismissStaleReviews: inputProperties.dismissStaleReviews,
31
+ requiredStatusCheckContexts: inputProperties.requiredStatusCheckContexts,
32
+ requireBranchesToBeUpToDate: inputProperties.requireBranchesToBeUpToDate,
33
+ requiredConversationResolution: inputProperties.requiredConversationResolution,
34
+ requireLastPushApproval: inputProperties.requireLastPushApproval,
35
+ repoVisibility: inputProperties.repoVisibility,
36
+ defaultBranch: inputProperties.defaultBranch,
37
+ protectDefaultBranch: inputProperties.protectDefaultBranch,
38
+ protectEnforceAdmins: inputProperties.protectEnforceAdmins,
39
+ deleteBranchOnMerge: inputProperties.deleteBranchOnMerge,
40
+ gitCommitMessage: inputProperties.gitCommitMessage,
41
+ gitAuthorName: inputProperties.gitAuthorName,
42
+ gitAuthorEmail: inputProperties.gitAuthorEmail,
43
+ allowMergeCommit: inputProperties.allowMergeCommit,
44
+ allowSquashMerge: inputProperties.allowSquashMerge,
45
+ squashMergeCommitTitle: inputProperties.squashMergeCommitTitle,
46
+ squashMergeCommitMessage: inputProperties.squashMergeCommitMessage,
47
+ allowRebaseMerge: inputProperties.allowRebaseMerge,
48
+ allowAutoMerge: inputProperties.allowAutoMerge,
49
+ sourcePath: inputProperties.sourcePath,
50
+ collaborators: inputProperties.collaborators,
51
+ hasProjects: inputProperties.hasProjects,
52
+ hasWiki: inputProperties.hasWiki,
53
+ hasIssues: inputProperties.hasIssues,
54
+ token: inputProperties.token,
55
+ topics: inputProperties.topics,
56
+ repoVariables: inputProperties.repoVariables,
57
+ secrets: inputProperties.secrets,
58
+ oidcCustomization: inputProperties.oidcCustomization,
59
+ requiredCommitSigning: inputProperties.requiredCommitSigning,
60
+ customProperties: inputProperties.customProperties
61
+ }
62
+ },
63
+ output: {
64
+ type: "object",
65
+ properties: {
66
+ remoteUrl: outputProperties.remoteUrl,
67
+ repoContentsUrl: outputProperties.repoContentsUrl,
68
+ commitHash: outputProperties.commitHash
69
+ }
70
+ }
71
+ },
72
+ async handler(ctx) {
73
+ const {
74
+ repoUrl,
75
+ description,
76
+ homepage,
77
+ access,
78
+ requireCodeOwnerReviews = false,
79
+ dismissStaleReviews = false,
80
+ bypassPullRequestAllowances,
81
+ requiredApprovingReviewCount = 1,
82
+ restrictions,
83
+ requiredStatusCheckContexts = [],
84
+ requireBranchesToBeUpToDate = true,
85
+ requiredConversationResolution = false,
86
+ requireLastPushApproval = false,
87
+ repoVisibility = "private",
88
+ defaultBranch = "master",
89
+ protectDefaultBranch = true,
90
+ protectEnforceAdmins = true,
91
+ deleteBranchOnMerge = false,
92
+ gitCommitMessage,
93
+ gitAuthorName,
94
+ gitAuthorEmail,
95
+ allowMergeCommit = true,
96
+ allowSquashMerge = true,
97
+ squashMergeCommitTitle = "COMMIT_OR_PR_TITLE",
98
+ squashMergeCommitMessage = "COMMIT_MESSAGES",
99
+ allowRebaseMerge = true,
100
+ allowAutoMerge = false,
101
+ collaborators,
102
+ hasProjects = void 0,
103
+ hasWiki = void 0,
104
+ hasIssues = void 0,
105
+ topics,
106
+ repoVariables,
107
+ secrets,
108
+ oidcCustomization,
109
+ token: providedToken,
110
+ customProperties,
111
+ requiredCommitSigning = false
112
+ } = ctx.input;
113
+ const octokitOptions = await helpers.getOctokitOptions({
114
+ integrations,
115
+ credentialsProvider: githubCredentialsProvider,
116
+ token: providedToken,
117
+ repoUrl
118
+ });
119
+ const client = new octokit.Octokit(octokitOptions);
120
+ const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
121
+ if (!owner) {
122
+ throw new errors.InputError("Invalid repository owner provided in repoUrl");
123
+ }
124
+ const newRepo = await helpers.createGithubRepoWithCollaboratorsAndTopics(
125
+ client,
126
+ repo,
127
+ owner,
128
+ repoVisibility,
129
+ description,
130
+ homepage,
131
+ deleteBranchOnMerge,
132
+ allowMergeCommit,
133
+ allowSquashMerge,
134
+ squashMergeCommitTitle,
135
+ squashMergeCommitMessage,
136
+ allowRebaseMerge,
137
+ allowAutoMerge,
138
+ access,
139
+ collaborators,
140
+ hasProjects,
141
+ hasWiki,
142
+ hasIssues,
143
+ topics,
144
+ repoVariables,
145
+ secrets,
146
+ oidcCustomization,
147
+ customProperties,
148
+ ctx.logger
149
+ );
150
+ const remoteUrl = newRepo.clone_url;
151
+ const repoContentsUrl = `${newRepo.html_url}/blob/${defaultBranch}`;
152
+ const commitResult = await helpers.initRepoPushAndProtect(
153
+ remoteUrl,
154
+ octokitOptions.auth,
155
+ ctx.workspacePath,
156
+ ctx.input.sourcePath,
157
+ defaultBranch,
158
+ protectDefaultBranch,
159
+ protectEnforceAdmins,
160
+ owner,
161
+ client,
162
+ repo,
163
+ requireCodeOwnerReviews,
164
+ bypassPullRequestAllowances,
165
+ requiredApprovingReviewCount,
166
+ restrictions,
167
+ requiredStatusCheckContexts,
168
+ requireBranchesToBeUpToDate,
169
+ requiredConversationResolution,
170
+ requireLastPushApproval,
171
+ config,
172
+ ctx.logger,
173
+ gitCommitMessage,
174
+ gitAuthorName,
175
+ gitAuthorEmail,
176
+ dismissStaleReviews,
177
+ requiredCommitSigning
178
+ );
179
+ ctx.output("commitHash", commitResult?.commitHash);
180
+ ctx.output("remoteUrl", remoteUrl);
181
+ ctx.output("repoContentsUrl", repoContentsUrl);
182
+ }
183
+ });
184
+ }
185
+
186
+ exports.createPublishGithubAction = createPublishGithubAction;
187
+ //# sourceMappingURL=github.cjs.js.map
@@ -0,0 +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 getOctokitOptions,\n initRepoPushAndProtect,\n} from './helpers';\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}) {\n const { integrations, config, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n homepage?: string;\n access?: string;\n defaultBranch?: string;\n protectDefaultBranch?: boolean;\n protectEnforceAdmins?: boolean;\n deleteBranchOnMerge?: boolean;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n allowRebaseMerge?: boolean;\n allowSquashMerge?: boolean;\n squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE';\n squashMergeCommitMessage?: 'PR_BODY' | 'COMMIT_MESSAGES' | 'BLANK';\n allowMergeCommit?: boolean;\n allowAutoMerge?: boolean;\n sourcePath?: string;\n bypassPullRequestAllowances?:\n | {\n users?: string[];\n teams?: string[];\n apps?: string[];\n }\n | undefined;\n requiredApprovingReviewCount?: number;\n restrictions?:\n | {\n users: string[];\n teams: string[];\n apps?: string[];\n }\n | undefined;\n requireCodeOwnerReviews?: boolean;\n dismissStaleReviews?: boolean;\n requiredStatusCheckContexts?: string[];\n requireBranchesToBeUpToDate?: boolean;\n requiredConversationResolution?: boolean;\n requireLastPushApproval?: boolean;\n repoVisibility?: 'private' | 'internal' | 'public';\n collaborators?: Array<\n | {\n user: string;\n access: string;\n }\n | {\n team: string;\n access: string;\n }\n | {\n /** @deprecated This field is deprecated in favor of team */\n username: string;\n access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';\n }\n >;\n hasProjects?: boolean | undefined;\n hasWiki?: boolean | undefined;\n hasIssues?: boolean | undefined;\n token?: string;\n topics?: string[];\n repoVariables?: { [key: string]: string };\n secrets?: { [key: string]: string };\n oidcCustomization?: {\n useDefault: boolean;\n includeClaimKeys?: string[];\n };\n requiredCommitSigning?: boolean;\n customProperties?: { [key: string]: string };\n }>({\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 type: 'object',\n required: ['repoUrl'],\n properties: {\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 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 customProperties: inputProps.customProperties,\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: outputProps.remoteUrl,\n repoContentsUrl: outputProps.repoContentsUrl,\n commitHash: outputProps.commitHash,\n },\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 = 'master',\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 collaborators,\n hasProjects = undefined,\n hasWiki = undefined,\n hasIssues = undefined,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n token: providedToken,\n customProperties,\n requiredCommitSigning = false,\n } = ctx.input;\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n repoUrl: repoUrl,\n });\n const client = new Octokit(octokitOptions);\n\n const { owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\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 access,\n collaborators,\n hasProjects,\n hasWiki,\n hasIssues,\n topics,\n repoVariables,\n secrets,\n oidcCustomization,\n customProperties,\n ctx.logger,\n );\n\n const remoteUrl = newRepo.clone_url;\n const repoContentsUrl = `${newRepo.html_url}/blob/${defaultBranch}`;\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 );\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.sourcePath","inputProps.collaborators","inputProps.hasProjects","inputProps.hasWiki","inputProps.hasIssues","inputProps.token","inputProps.topics","inputProps.repoVariables","inputProps.secrets","inputProps.oidcCustomization","inputProps.requiredCommitSigning","inputProps.customProperties","outputProps.remoteUrl","outputProps.repoContentsUrl","outputProps.commitHash","getOctokitOptions","Octokit","parseRepoUrl","InputError","createGithubRepoWithCollaboratorsAndTopics","initRepoPushAndProtect"],"mappings":";;;;;;;;;;AA0CO,SAAS,0BAA0B,OAIvC,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAQ,EAAA,yBAAA,EAA8B,GAAA,OAAA,CAAA;AAE5D,EAAA,OAAOA,yCAqEJ,CAAA;AAAA,IACD,EAAI,EAAA,gBAAA;AAAA,IACJ,WAC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zB,SAAA;AAAA,QACA,cAAe,CAAA,IAAA;AAAA,QACf,GAAI,CAAA,aAAA;AAAA,QACJ,IAAI,KAAM,CAAA,UAAA;AAAA,QACV,aAAA;AAAA,QACA,oBAAA;AAAA,QACA,oBAAA;AAAA,QACA,KAAA;AAAA,QACA,MAAA;AAAA,QACA,IAAA;AAAA,QACA,uBAAA;AAAA,QACA,2BAAA;AAAA,QACA,4BAAA;AAAA,QACA,YAAA;AAAA,QACA,2BAAA;AAAA,QACA,2BAAA;AAAA,QACA,8BAAA;AAAA,QACA,uBAAA;AAAA,QACA,MAAA;AAAA,QACA,GAAI,CAAA,MAAA;AAAA,QACJ,gBAAA;AAAA,QACA,aAAA;AAAA,QACA,cAAA;AAAA,QACA,mBAAA;AAAA,QACA,qBAAA;AAAA,OACF,CAAA;AAEA,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAAA,KAC/C;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "Initializes a git repository with the content in the workspace, and publishes it to GitHub with the default configuration.",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ id: "publish",
16
+ action: "publish:github",
17
+ name: "Publish to GitHub",
18
+ input: {
19
+ repoUrl: "github.com?repo=repo&owner=owner"
20
+ }
21
+ }
22
+ ]
23
+ })
24
+ },
25
+ {
26
+ description: "Initializes a GitHub repository with a description.",
27
+ example: yaml__default.default.stringify({
28
+ steps: [
29
+ {
30
+ id: "publish",
31
+ action: "publish:github",
32
+ name: "Publish to GitHub",
33
+ input: {
34
+ repoUrl: "github.com?repo=repo&owner=owner",
35
+ description: "Initialize a git repository"
36
+ }
37
+ }
38
+ ]
39
+ })
40
+ },
41
+ {
42
+ description: "Initializes a GitHub repository with public repo visibility, if not set defaults to private",
43
+ example: yaml__default.default.stringify({
44
+ steps: [
45
+ {
46
+ id: "publish",
47
+ action: "publish:github",
48
+ name: "Publish to GitHub",
49
+ input: {
50
+ repoUrl: "github.com?repo=repo&owner=owner",
51
+ repoVisibility: "public"
52
+ }
53
+ }
54
+ ]
55
+ })
56
+ }
57
+ ];
58
+
59
+ exports.examples = examples;
60
+ //# sourceMappingURL=github.examples.cjs.js.map
@@ -0,0 +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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,4HAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,gBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,WACX;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,qDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,gBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,WAAa,EAAA,6BAAA;AAAA,WACf;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,6FAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,gBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,cAAgB,EAAA,QAAA;AAAA,WAClB;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
5
+ var octokit = require('octokit');
6
+ var helpers = require('./helpers.cjs.js');
7
+ var githubActionsDispatch_examples = require('./githubActionsDispatch.examples.cjs.js');
8
+
9
+ function createGithubActionsDispatchAction(options) {
10
+ const { integrations, githubCredentialsProvider } = options;
11
+ return pluginScaffolderNode.createTemplateAction({
12
+ id: "github:actions:dispatch",
13
+ description: "Dispatches a GitHub Action workflow for a given branch or tag",
14
+ examples: githubActionsDispatch_examples.examples,
15
+ schema: {
16
+ input: {
17
+ type: "object",
18
+ required: ["repoUrl", "workflowId", "branchOrTagName"],
19
+ properties: {
20
+ repoUrl: {
21
+ title: "Repository Location",
22
+ description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
23
+ type: "string"
24
+ },
25
+ workflowId: {
26
+ title: "Workflow ID",
27
+ description: "The GitHub Action Workflow filename",
28
+ type: "string"
29
+ },
30
+ branchOrTagName: {
31
+ title: "Branch or Tag name",
32
+ description: "The git branch or tag name used to dispatch the workflow",
33
+ type: "string"
34
+ },
35
+ workflowInputs: {
36
+ title: "Workflow Inputs",
37
+ description: "Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10. ",
38
+ type: "object"
39
+ },
40
+ token: {
41
+ title: "Authentication Token",
42
+ type: "string",
43
+ description: "The GITHUB_TOKEN to use for authorization to GitHub"
44
+ }
45
+ }
46
+ }
47
+ },
48
+ async handler(ctx) {
49
+ const {
50
+ repoUrl,
51
+ workflowId,
52
+ branchOrTagName,
53
+ workflowInputs,
54
+ token: providedToken
55
+ } = ctx.input;
56
+ ctx.logger.info(
57
+ `Dispatching workflow ${workflowId} for repo ${repoUrl} on ${branchOrTagName}`
58
+ );
59
+ const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
60
+ if (!owner) {
61
+ throw new errors.InputError("Invalid repository owner provided in repoUrl");
62
+ }
63
+ const client = new octokit.Octokit(
64
+ await helpers.getOctokitOptions({
65
+ integrations,
66
+ repoUrl,
67
+ credentialsProvider: githubCredentialsProvider,
68
+ token: providedToken
69
+ })
70
+ );
71
+ await client.rest.actions.createWorkflowDispatch({
72
+ owner,
73
+ repo,
74
+ workflow_id: workflowId,
75
+ ref: branchOrTagName,
76
+ inputs: workflowInputs
77
+ });
78
+ ctx.logger.info(`Workflow ${workflowId} dispatched successfully`);
79
+ }
80
+ });
81
+ }
82
+
83
+ exports.createGithubActionsDispatchAction = createGithubActionsDispatchAction;
84
+ //# sourceMappingURL=githubActionsDispatch.cjs.js.map
@@ -0,0 +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 } 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 './helpers';\nimport { examples } from './githubActionsDispatch.examples';\n\n/**\n * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.\n * @public\n */\nexport function createGithubActionsDispatchAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n workflowId: string;\n branchOrTagName: string;\n workflowInputs?: { [key: string]: string };\n token?: string;\n }>({\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 type: 'object',\n required: ['repoUrl', 'workflowId', 'branchOrTagName'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,\n type: 'string',\n },\n workflowId: {\n title: 'Workflow ID',\n description: 'The GitHub Action Workflow filename',\n type: 'string',\n },\n branchOrTagName: {\n title: 'Branch or Tag name',\n description:\n 'The git branch or tag name used to dispatch the workflow',\n type: 'string',\n },\n workflowInputs: {\n title: 'Workflow Inputs',\n description:\n 'Inputs keys and values to send to GitHub Action configured on the workflow file. The maximum number of properties is 10. ',\n type: 'object',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The GITHUB_TOKEN to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n workflowId,\n branchOrTagName,\n workflowInputs,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(\n `Dispatching workflow ${workflowId} for repo ${repoUrl} on ${branchOrTagName}`,\n );\n\n const { owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const client = new Octokit(\n await getOctokitOptions({\n integrations,\n repoUrl,\n credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n }),\n );\n\n await client.rest.actions.createWorkflowDispatch({\n owner,\n repo,\n workflow_id: workflowId,\n ref: branchOrTagName,\n inputs: workflowInputs,\n });\n\n ctx.logger.info(`Workflow ${workflowId} dispatched successfully`);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Octokit","getOctokitOptions"],"mappings":";;;;;;;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,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,QACT,CAAwB,qBAAA,EAAA,UAAU,CAAa,UAAA,EAAA,OAAO,OAAO,eAAe,CAAA,CAAA;AAAA,OAC9E,CAAA;AAEA,MAAA,MAAM,EAAE,KAAO,EAAA,IAAA,EAAS,GAAAC,iCAAA,CAAa,SAAS,YAAY,CAAA,CAAA;AAE1D,MAAA,IAAI,CAAC,KAAO,EAAA;AACV,QAAM,MAAA,IAAIC,kBAAW,8CAA8C,CAAA,CAAA;AAAA,OACrE;AAEA,MAAA,MAAM,SAAS,IAAIC,eAAA;AAAA,QACjB,MAAMC,yBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,OAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB,KAAO,EAAA,aAAA;AAAA,SACR,CAAA;AAAA,OACH,CAAA;AAEA,MAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,sBAAuB,CAAA;AAAA,QAC/C,KAAA;AAAA,QACA,IAAA;AAAA,QACA,WAAa,EAAA,UAAA;AAAA,QACb,GAAK,EAAA,eAAA;AAAA,QACL,MAAQ,EAAA,cAAA;AAAA,OACT,CAAA,CAAA;AAED,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAA0B,wBAAA,CAAA,CAAA,CAAA;AAAA,KAClE;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "GitHub Action Workflow Without Inputs.",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ action: "github:actions:dispatch",
16
+ name: "Dispatch Github Action Workflow",
17
+ input: {
18
+ repoUrl: "github.com?repo=repo&owner=owner",
19
+ workflowId: "WORKFLOW_ID",
20
+ branchOrTagName: "main"
21
+ }
22
+ }
23
+ ]
24
+ })
25
+ },
26
+ {
27
+ description: "GitHub Action Workflow With Inputs",
28
+ example: yaml__default.default.stringify({
29
+ steps: [
30
+ {
31
+ action: "github:actions:dispatch",
32
+ name: "Dispatch Github Action Workflow with inputs",
33
+ input: {
34
+ repoUrl: "github.com?repo=repo&owner=owner",
35
+ workflowId: "WORKFLOW_ID",
36
+ branchOrTagName: "main",
37
+ workflowInputs: {
38
+ input1: "value1",
39
+ input2: "value2"
40
+ }
41
+ }
42
+ }
43
+ ]
44
+ })
45
+ },
46
+ {
47
+ description: "GitHub Action Workflow With Custom Token",
48
+ example: yaml__default.default.stringify({
49
+ steps: [
50
+ {
51
+ action: "github:actions:dispatch",
52
+ name: "Dispatch GitHub Action Workflow (custom token)",
53
+ input: {
54
+ repoUrl: "github.com?repo=reponame&owner=owner",
55
+ workflowId: "WORKFLOW_ID",
56
+ branchOrTagName: "release-1.0",
57
+ token: "${{ secrets.MY_CUSTOM_TOKEN }}"
58
+ }
59
+ }
60
+ ]
61
+ })
62
+ }
63
+ ];
64
+
65
+ exports.examples = examples;
66
+ //# sourceMappingURL=githubActionsDispatch.examples.cjs.js.map
@@ -0,0 +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"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,wCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,iCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,aAAA;AAAA,YACZ,eAAiB,EAAA,MAAA;AAAA,WACnB;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,oCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,6CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,UAAY,EAAA,aAAA;AAAA,YACZ,eAAiB,EAAA,MAAA;AAAA,YACjB,cAAgB,EAAA;AAAA,cACd,MAAQ,EAAA,QAAA;AAAA,cACR,MAAQ,EAAA,QAAA;AAAA,aACV;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,0CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,gDAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,sCAAA;AAAA,YACT,UAAY,EAAA,aAAA;AAAA,YACZ,eAAiB,EAAA,aAAA;AAAA,YACjB,KAAO,EAAA,gCAAA;AAAA,WACT;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
5
+ var octokit = require('octokit');
6
+ var githubAutolinks_examples = require('./githubAutolinks.examples.cjs.js');
7
+ var helpers = require('./helpers.cjs.js');
8
+
9
+ function createGithubAutolinksAction(options) {
10
+ const { integrations, githubCredentialsProvider } = options;
11
+ return pluginScaffolderNode.createTemplateAction({
12
+ id: "github:autolinks:create",
13
+ description: "Create an autolink reference for a repository",
14
+ examples: githubAutolinks_examples.examples,
15
+ schema: {
16
+ input: {
17
+ type: "object",
18
+ required: ["repoUrl", "keyPrefix", "urlTemplate"],
19
+ properties: {
20
+ repoUrl: {
21
+ title: "Repository Location",
22
+ description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
23
+ type: "string"
24
+ },
25
+ keyPrefix: {
26
+ title: "Key Prefix",
27
+ description: "This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.",
28
+ type: "string"
29
+ },
30
+ urlTemplate: {
31
+ title: "URL Template",
32
+ description: "The URL must contain <num> for the reference number. <num> matches different characters depending on the value of isAlphanumeric.",
33
+ type: "string"
34
+ },
35
+ isAlphanumeric: {
36
+ title: "Alphanumeric",
37
+ description: "Whether this autolink reference matches alphanumeric characters. If true, the <num> parameter of the url_template matches alphanumeric characters A-Z (case insensitive), 0-9, and -. If false, this autolink reference only matches numeric characters. Default: true",
38
+ type: "boolean"
39
+ },
40
+ token: {
41
+ title: "Authentication Token",
42
+ type: "string",
43
+ description: "The token to use for authorization to GitHub"
44
+ }
45
+ }
46
+ }
47
+ },
48
+ async handler(ctx) {
49
+ const { repoUrl, keyPrefix, urlTemplate, isAlphanumeric, token } = ctx.input;
50
+ ctx.logger.info(`Creating autolink reference for repo ${repoUrl}`);
51
+ const { owner, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
52
+ if (!owner) {
53
+ throw new errors.InputError("Invalid repository owner provided in repoUrl");
54
+ }
55
+ const client = new octokit.Octokit(
56
+ await helpers.getOctokitOptions({
57
+ integrations,
58
+ repoUrl,
59
+ credentialsProvider: githubCredentialsProvider,
60
+ token
61
+ })
62
+ );
63
+ await client.rest.repos.createAutolink({
64
+ owner,
65
+ repo,
66
+ key_prefix: keyPrefix,
67
+ url_template: urlTemplate,
68
+ is_alphanumeric: isAlphanumeric
69
+ });
70
+ ctx.logger.info(`Autolink reference created successfully`);
71
+ }
72
+ });
73
+ }
74
+
75
+ exports.createGithubAutolinksAction = createGithubAutolinksAction;
76
+ //# sourceMappingURL=githubAutolinks.cjs.js.map
@@ -0,0 +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 './helpers';\n\n/**\n * Create an autolink reference for a repository\n * @public\n */\nexport function createGithubAutolinksAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n keyPrefix: string;\n urlTemplate: string;\n isAlphanumeric?: boolean;\n token?: string;\n }>({\n id: 'github:autolinks:create',\n description: 'Create an autolink reference for a repository',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'keyPrefix', 'urlTemplate'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,\n type: 'string',\n },\n keyPrefix: {\n title: 'Key Prefix',\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 type: 'string',\n },\n urlTemplate: {\n title: 'URL Template',\n description:\n 'The URL must contain <num> for the reference number. <num> matches different characters depending on the value of isAlphanumeric.',\n type: 'string',\n },\n isAlphanumeric: {\n title: 'Alphanumeric',\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 type: 'boolean',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\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 { owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const client = new Octokit(\n await getOctokitOptions({\n integrations,\n repoUrl,\n credentialsProvider: githubCredentialsProvider,\n token,\n }),\n );\n\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"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Octokit","getOctokitOptions"],"mappings":";;;;;;;;AAiCO,SAAS,4BAA4B,OAGzC,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA,CAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WAAa,EAAA,+CAAA;AAAA,cACbC,iCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAU,EAAA,CAAC,SAAW,EAAA,WAAA,EAAa,aAAa,CAAA;AAAA,QAChD,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WAAa,EAAA,CAAA,gJAAA,CAAA;AAAA,YACb,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,SAAW,EAAA;AAAA,YACT,KAAO,EAAA,YAAA;AAAA,YACP,WACE,EAAA,4H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ACd,eAAiB,EAAA,cAAA;AAAA,OAClB,CAAA,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,KAAK,CAAyC,uCAAA,CAAA,CAAA,CAAA;AAAA,KAC3D;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "GitHub alphanumric autolink reference",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ action: "github:autolinks:create",
16
+ name: "Create an autolink reference",
17
+ input: {
18
+ repoUrl: "github.com?repo=repo&owner=owner",
19
+ keyPrefix: "TICKET-",
20
+ urlTemplate: "https://example.com/TICKET?query=<num>",
21
+ isAlphanumeric: false
22
+ }
23
+ }
24
+ ]
25
+ })
26
+ }
27
+ ];
28
+
29
+ exports.examples = examples;
30
+ //# sourceMappingURL=githubAutolinks.examples.cjs.js.map
@@ -0,0 +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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,uCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,IAAM,EAAA,8BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,SAAA;AAAA,YACX,WAAa,EAAA,wCAAA;AAAA,YACb,cAAgB,EAAA,KAAA;AAAA,WAClB;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}