@backstage/plugin-scaffolder-backend-module-github 0.6.0-next.2 → 0.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-github
2
2
 
3
+ ## 0.6.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-plugin-api@1.2.1-next.0
9
+ - @backstage/plugin-scaffolder-node@0.7.1-next.0
10
+
11
+ ## 0.6.0
12
+
13
+ ### Minor Changes
14
+
15
+ - bb8302b: **BREAKING**: The `remoteUrl` output is no longer required, it can be empty only when using the new `createWhenEmpty` boolean flag.
16
+
17
+ ### Patch Changes
18
+
19
+ - 5c187f9: **DEPRECATION**: The `getOctokitOptions` function signature with `repoUrl` option has been deprecated in favour of a function signature with individual `host`, `owner`, and `repo` parameters:
20
+
21
+ ```diff
22
+ const octokitOptions = await getOctokitOptions({
23
+ integrations,
24
+ credentialsProvider,
25
+ token,
26
+ - repoUrl,
27
+ + host,
28
+ + owner,
29
+ + repo,
30
+ });
31
+ ```
32
+
33
+ - b98d511: clean up github action schemas
34
+ - 5d469c9: Added support for autocompletion of GitHub branches in scaffolder
35
+ - 8e67e4a: Added support for autocompletion to GithubRepoPicker component
36
+ - Updated dependencies
37
+ - @backstage/backend-plugin-api@1.2.0
38
+ - @backstage/plugin-scaffolder-node@0.7.0
39
+ - @backstage/catalog-client@1.9.1
40
+ - @backstage/catalog-model@1.7.3
41
+ - @backstage/config@1.3.2
42
+ - @backstage/errors@1.2.7
43
+ - @backstage/integration@1.16.1
44
+
3
45
  ## 0.6.0-next.2
4
46
 
5
47
  ### Minor Changes
@@ -19,7 +19,7 @@ function createGithubActionsDispatchAction(options) {
19
19
  properties: {
20
20
  repoUrl: {
21
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`,
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
23
  type: "string"
24
24
  },
25
25
  workflowId: {
@@ -40,7 +40,7 @@ function createGithubActionsDispatchAction(options) {
40
40
  token: {
41
41
  title: "Authentication Token",
42
42
  type: "string",
43
- description: "The GITHUB_TOKEN to use for authorization to GitHub"
43
+ description: "The `GITHUB_TOKEN` to use for authorization to GitHub"
44
44
  }
45
45
  }
46
46
  }
@@ -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 } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubActionsDispatch.examples';\n\n/**\n * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.\n * @public\n */\nexport function createGithubActionsDispatchAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n 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 { host, 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 host,\n owner,\n repo,\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":";;;;;;;;AAiCO,SAAS,kCAAkC,OAG/C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WACE,EAAA,+DAAA;AAAA,cAC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M,MAAA,IAAIC,kBAAW,8CAA8C,CAAA;AAAA;AAGrE,MAAA,MAAM,SAAS,IAAIC,eAAA;AAAA,QACjB,MAAMC,sBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB,KAAO,EAAA;AAAA,SACR;AAAA,OACH;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;AAAA,OACT,CAAA;AAED,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAA0B,wBAAA,CAAA,CAAA;AAAA;AAClE,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 } from '@backstage/errors';\nimport {\n GithubCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubActionsDispatch.examples';\n\n/**\n * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.\n * @public\n */\nexport function createGithubActionsDispatchAction(options: {\n integrations: ScmIntegrations;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n 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:\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 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:\n '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 { host, 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 host,\n owner,\n repo,\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":";;;;;;;;AAiCO,SAAS,kCAAkC,OAG/C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WACE,EAAA,+DAAA;AAAA,cACFC,uCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAU,EAAA,CAAC,SAAW,EAAA,YAAA,EAAc,iBAAiB,CAAA;AAAA,QACrD,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,UAAY,EAAA;AAAA,YACV,KAAO,EAAA,aAAA;AAAA,YACP,WAAa,EAAA,qCAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,eAAiB,EAAA;AAAA,YACf,KAAO,EAAA,oBAAA;AAAA,YACP,WACE,EAAA,0DAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,cAAgB,EAAA;AAAA,YACd,KAAO,EAAA,iBAAA;AAAA,YACP,WACE,EAAA,2HAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,KAAO,EAAA;AAAA,YACL,KAAO,EAAA,sBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WACE,EAAA;AAAA;AACJ;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAM,MAAA;AAAA,QACJ,OAAA;AAAA,QACA,UAAA;AAAA,QACA,eAAA;AAAA,QACA,cAAA;AAAA,QACA,KAAO,EAAA;AAAA,UACL,GAAI,CAAA,KAAA;AAER,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,QACT,CAAwB,qBAAA,EAAA,UAAU,CAAa,UAAA,EAAA,OAAO,OAAO,eAAe,CAAA;AAAA,OAC9E;AAEA,MAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,MAAS,GAAAC,iCAAA,CAAa,SAAS,YAAY,CAAA;AAEhE,MAAA,IAAI,CAAC,KAAO,EAAA;AACV,QAAM,MAAA,IAAIC,kBAAW,8CAA8C,CAAA;AAAA;AAGrE,MAAA,MAAM,SAAS,IAAIC,eAAA;AAAA,QACjB,MAAMC,sBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB,KAAO,EAAA;AAAA,SACR;AAAA,OACH;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;AAAA,OACT,CAAA;AAED,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAA0B,wBAAA,CAAA,CAAA;AAAA;AAClE,GACD,CAAA;AACH;;;;"}
@@ -19,7 +19,7 @@ function createGithubAutolinksAction(options) {
19
19
  properties: {
20
20
  repoUrl: {
21
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`,
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
23
  type: "string"
24
24
  },
25
25
  keyPrefix: {
@@ -29,13 +29,14 @@ function createGithubAutolinksAction(options) {
29
29
  },
30
30
  urlTemplate: {
31
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.",
32
+ description: "The URL must contain `<num>` for the reference number. `<num>` matches different characters depending on the value of isAlphanumeric.",
33
33
  type: "string"
34
34
  },
35
35
  isAlphanumeric: {
36
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"
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
+ default: true
39
40
  },
40
41
  token: {
41
42
  title: "Authentication Token",
@@ -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}) {\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 { host, 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 host,\n owner,\n repo,\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,MA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,SAAS,YAAY,CAAA;AAEhE,MAAA,IAAI,CAAC,KAAO,EAAA;AACV,QAAM,MAAA,IAAIC,kBAAW,8CAA8C,CAAA;AAAA;AAGrE,MAAA,MAAM,SAAS,IAAIC,eAAA;AAAA,QACjB,MAAMC,sBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB;AAAA,SACD;AAAA,OACH;AAEA,MAAM,MAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,cAAe,CAAA;AAAA,QACrC,KAAA;AAAA,QACA,IAAA;AAAA,QACA,UAAY,EAAA,SAAA;AAAA,QACZ,YAAc,EAAA,WAAA;AAAA,QACd,eAAiB,EAAA;AAAA,OAClB,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,KAAK,CAAyC,uCAAA,CAAA,CAAA;AAAA;AAC3D,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}) {\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:\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 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 default: true,\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 { host, 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 host,\n owner,\n repo,\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;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,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,SAAW,EAAA;AAAA,YACT,KAAO,EAAA,YAAA;AAAA,YACP,WACE,EAAA,4HAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,WAAa,EAAA;AAAA,YACX,KAAO,EAAA,cAAA;AAAA,YACP,WACE,EAAA,uIAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,cAAgB,EAAA;AAAA,YACd,KAAO,EAAA,cAAA;AAAA,YACP,WACE,EAAA,wRAAA;AAAA,YACF,IAAM,EAAA,SAAA;AAAA,YACN,OAAS,EAAA;AAAA,WACX;AAAA,UACA,KAAO,EAAA;AAAA,YACL,KAAO,EAAA,sBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA;AAAA;AACf;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,EAAE,OAAS,EAAA,SAAA,EAAW,aAAa,cAAgB,EAAA,KAAA,KACvD,GAAI,CAAA,KAAA;AAEN,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAwC,qCAAA,EAAA,OAAO,CAAE,CAAA,CAAA;AAEjE,MAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,MAAS,GAAAC,iCAAA,CAAa,SAAS,YAAY,CAAA;AAEhE,MAAA,IAAI,CAAC,KAAO,EAAA;AACV,QAAM,MAAA,IAAIC,kBAAW,8CAA8C,CAAA;AAAA;AAGrE,MAAA,MAAM,SAAS,IAAIC,eAAA;AAAA,QACjB,MAAMC,sBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB;AAAA,SACD;AAAA,OACH;AAEA,MAAM,MAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,cAAe,CAAA;AAAA,QACrC,KAAA;AAAA,QACA,IAAA;AAAA,QACA,UAAY,EAAA,SAAA;AAAA,QACZ,YAAc,EAAA,WAAA;AAAA,QACd,eAAiB,EAAA;AAAA,OAClB,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,KAAK,CAAyC,uCAAA,CAAA,CAAA;AAAA;AAC3D,GACD,CAAA;AACH;;;;"}
@@ -24,17 +24,17 @@ function createGithubDeployKeyAction(options) {
24
24
  properties: {
25
25
  repoUrl: {
26
26
  title: "Repository Location",
27
- description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
27
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username",
28
28
  type: "string"
29
29
  },
30
30
  publicKey: {
31
31
  title: "SSH Public Key",
32
- description: `Generated from ssh-keygen. Begins with 'ssh-rsa', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'ssh-ed25519', 'sk-ecdsa-sha2-nistp256@openssh.com', or 'sk-ssh-ed25519@openssh.com'.`,
32
+ description: "Generated from `ssh-keygen`. Begins with `ssh-rsa`, `ecdsa-sha2-nistp256`, `ecdsa-sha2-nistp384`, `ecdsa-sha2-nistp521`, `ssh-ed25519`, `sk-ecdsa-sha2-nistp256@openssh.com`, or `sk-ssh-ed25519@openssh.com`.",
33
33
  type: "string"
34
34
  },
35
35
  privateKey: {
36
36
  title: "SSH Private Key",
37
- description: `SSH Private Key generated from ssh-keygen`,
37
+ description: "SSH Private Key generated from `ssh-keygen`",
38
38
  type: "string"
39
39
  },
40
40
  deployKeyName: {
@@ -44,7 +44,7 @@ function createGithubDeployKeyAction(options) {
44
44
  },
45
45
  privateKeySecretName: {
46
46
  title: "Private Key GitHub Secret Name",
47
- description: `Name of the GitHub Secret to store the private key related to the Deploy Key. Defaults to: 'KEY_NAME_PRIVATE_KEY' where 'KEY_NAME' is the name of the Deploy Key`,
47
+ description: "Name of the GitHub Secret to store the private key related to the Deploy Key. Defaults to: `KEY_NAME_PRIVATE_KEY` where `KEY_NAME` is the name of the Deploy Key",
48
48
  type: "string"
49
49
  },
50
50
  token: {
@@ -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}) {\n const { integrations } = 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 repoUrl: string;\n publicKey: string;\n privateKey: string;\n deployKeyName: string;\n privateKeySecretName?: string;\n token?: string;\n }>({\n id: 'github:deployKey:create',\n description: 'Creates and stores Deploy Keys',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'publicKey', 'privateKey', 'deployKeyName'],\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 publicKey: {\n title: 'SSH Public Key',\n description: `Generated from ssh-keygen. Begins with 'ssh-rsa', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'ssh-ed25519', 'sk-ecdsa-sha2-nistp256@openssh.com', or 'sk-ssh-ed25519@openssh.com'.`,\n type: 'string',\n },\n privateKey: {\n title: 'SSH Private Key',\n description: `SSH Private Key generated from ssh-keygen`,\n type: 'string',\n },\n deployKeyName: {\n title: 'Deploy Key Name',\n description: `Name of the Deploy Key`,\n type: 'string',\n },\n privateKeySecretName: {\n title: 'Private Key GitHub Secret Name',\n description: `Name of the GitHub Secret to store the private key related to the Deploy Key. Defaults to: 'KEY_NAME_PRIVATE_KEY' where 'KEY_NAME' is the name of the Deploy Key`,\n type: 'string',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n privateKeySecretName: {\n title: 'The GitHub Action Repo Secret Name for the Private Key',\n type: 'string',\n },\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 .toLocaleUpperCase('en-US')}_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 token: providedToken,\n host,\n owner,\n repo,\n });\n\n const client = new Octokit(octokitOptions);\n\n await client.rest.repos.createDeployKey({\n owner: owner,\n repo: repo,\n title: deployKeyName,\n key: publicKey,\n });\n const publicKeyResponse = await client.rest.actions.getRepoPublicKey({\n owner: owner,\n repo: repo,\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKeyResponse.data.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 client.rest.actions.createOrUpdateRepoSecret({\n owner: owner,\n repo: repo,\n secret_name: privateKeySecretName,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyResponse.data.key_id,\n });\n\n ctx.output('privateKeySecretName', privateKeySecretName);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAgCO,SAAS,4BAA4B,OAEzC,EAAA;AACD,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AAGzB,EAAA,OAAOA,yCAOJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WAAa,EAAA,gCAAA;AAAA,cACbC,iCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAU,EAAA,CAAC,SAAW,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AA;AAAA,QACAA,wBAAO,eAAgB,CAAA;AAAA,OACzB;AAEA,MAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,wBAAyB,CAAA;AAAA,QACjD,KAAA;AAAA,QACA,IAAA;AAAA,QACA,WAAa,EAAA,oBAAA;AAAA,QACb,eAAiB,EAAA,qBAAA;AAAA,QACjB,MAAA,EAAQ,kBAAkB,IAAK,CAAA;AAAA,OAChC,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,wBAAwB,oBAAoB,CAAA;AAAA;AACzD,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}) {\n const { integrations } = 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 repoUrl: string;\n publicKey: string;\n privateKey: string;\n deployKeyName: string;\n privateKeySecretName?: string;\n token?: string;\n }>({\n id: 'github:deployKey:create',\n description: 'Creates and stores Deploy Keys',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'publicKey', 'privateKey', 'deployKeyName'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\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 type: 'string',\n },\n publicKey: {\n title: 'SSH Public Key',\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 type: 'string',\n },\n privateKey: {\n title: 'SSH Private Key',\n description: 'SSH Private Key generated from `ssh-keygen`',\n type: 'string',\n },\n deployKeyName: {\n title: 'Deploy Key Name',\n description: `Name of the Deploy Key`,\n type: 'string',\n },\n privateKeySecretName: {\n title: 'Private Key GitHub Secret Name',\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 type: 'string',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n privateKeySecretName: {\n title: 'The GitHub Action Repo Secret Name for the Private Key',\n type: 'string',\n },\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 .toLocaleUpperCase('en-US')}_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 token: providedToken,\n host,\n owner,\n repo,\n });\n\n const client = new Octokit(octokitOptions);\n\n await client.rest.repos.createDeployKey({\n owner: owner,\n repo: repo,\n title: deployKeyName,\n key: publicKey,\n });\n const publicKeyResponse = await client.rest.actions.getRepoPublicKey({\n owner: owner,\n repo: repo,\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKeyResponse.data.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 client.rest.actions.createOrUpdateRepoSecret({\n owner: owner,\n repo: repo,\n secret_name: privateKeySecretName,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyResponse.data.key_id,\n });\n\n ctx.output('privateKeySecretName', privateKeySecretName);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAgCO,SAAS,4BAA4B,OAEzC,EAAA;AACD,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AAGzB,EAAA,OAAOA,yCAOJ,CAAA;AAAA,IACD,EAAI,EAAA,yBAAA;AAAA,IACJ,WAAa,EAAA,gCAAA;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,cAAc,eAAe,CAAA;AAAA,QAChE,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,SAAW,EAAA;AAAA,YACT,KAAO,EAAA,gBAAA;AAAA,YACP,WACE,EAAA,iNAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,UAAY,EAAA;AAAA,YACV,K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7 +24,7 @@ function createGithubEnvironmentAction(options) {
24
24
  properties: {
25
25
  repoUrl: {
26
26
  title: "Repository Location",
27
- description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
27
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username",
28
28
  type: "string"
29
29
  },
30
30
  name: {
@@ -34,18 +34,18 @@ function createGithubEnvironmentAction(options) {
34
34
  },
35
35
  deploymentBranchPolicy: {
36
36
  title: "Deployment Branch Policy",
37
- description: `The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.`,
37
+ description: "The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.",
38
38
  type: "object",
39
39
  required: ["protected_branches", "custom_branch_policies"],
40
40
  properties: {
41
41
  protected_branches: {
42
42
  title: "Protected Branches",
43
- description: `Whether only branches with branch protection rules can deploy to this environment. If protected_branches is true, custom_branch_policies must be false; if protected_branches is false, custom_branch_policies must be true.`,
43
+ description: "Whether only branches with branch protection rules can deploy to this environment. If `protected_branches` is `true`, `custom_branch_policies` must be `false`; if `protected_branches` is `false`, `custom_branch_policies` must be `true`.",
44
44
  type: "boolean"
45
45
  },
46
46
  custom_branch_policies: {
47
47
  title: "Custom Branch Policies",
48
- description: `Whether only branches that match the specified name patterns can deploy to this environment. If custom_branch_policies is true, protected_branches must be false; if custom_branch_policies is false, protected_branches must be true.`,
48
+ description: "Whether only branches that match the specified name patterns can deploy to this environment. If `custom_branch_policies` is `true`, `protected_branches` must be `false`; if `custom_branch_policies` is `false`, `protected_branches` must be `true`.",
49
49
  type: "boolean"
50
50
  }
51
51
  }
@@ -54,7 +54,7 @@ function createGithubEnvironmentAction(options) {
54
54
  title: "Custom Branch Policy Name",
55
55
  description: `The name pattern that branches must match in order to deploy to the environment.
56
56
 
57
- Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
57
+ Wildcard characters will not match \`/\`. For example, to match branches that begin with \`release/\` and contain an additional single slash, use \`release/*/*\`. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
58
58
  type: "array",
59
59
  items: {
60
60
  type: "string"
@@ -64,7 +64,7 @@ function createGithubEnvironmentAction(options) {
64
64
  title: "Custom Tag Policy Name",
65
65
  description: `The name pattern that tags must match in order to deploy to the environment.
66
66
 
67
- Wildcard characters will not match /. For example, to match tags that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
67
+ Wildcard characters will not match \`/\`. For example, to match tags that begin with \`release/\` and contain an additional single slash, use \`release/*/*\`. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,
68
68
  type: "array",
69
69
  items: {
70
70
  type: "string"
@@ -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 { CatalogApi } from '@backstage/catalog-client';\nimport { Entity } from '@backstage/catalog-model';\nimport { AuthService } from '@backstage/backend-plugin-api';\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 catalogClient?: CatalogApi;\n auth?: AuthService;\n}) {\n const { integrations, catalogClient, auth } = 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 repoUrl: string;\n name: string;\n deploymentBranchPolicy?: {\n protected_branches: boolean;\n custom_branch_policies: boolean;\n };\n customBranchPolicyNames?: string[];\n customTagPolicyNames?: string[];\n environmentVariables?: { [key: string]: string };\n secrets?: { [key: string]: string };\n token?: string;\n waitTimer?: number;\n preventSelfReview?: boolean;\n reviewers?: string[];\n }>({\n id: 'github:environment:create',\n description: 'Creates Deployment Environments',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'name'],\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 name: {\n title: 'Environment Name',\n description: `Name of the deployment environment to create`,\n type: 'string',\n },\n deploymentBranchPolicy: {\n title: 'Deployment Branch Policy',\n description: `The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.`,\n type: 'object',\n required: ['protected_branches', 'custom_branch_policies'],\n properties: {\n protected_branches: {\n title: 'Protected Branches',\n description: `Whether only branches with branch protection rules can deploy to this environment. If protected_branches is true, custom_branch_policies must be false; if protected_branches is false, custom_branch_policies must be true.`,\n type: 'boolean',\n },\n custom_branch_policies: {\n title: 'Custom Branch Policies',\n description: `Whether only branches that match the specified name patterns can deploy to this environment. If custom_branch_policies is true, protected_branches must be false; if custom_branch_policies is false, protected_branches must be true.`,\n type: 'boolean',\n },\n },\n },\n customBranchPolicyNames: {\n title: 'Custom Branch Policy Name',\n description: `The name pattern that branches must match in order to deploy to the environment.\n\n Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,\n type: 'array',\n items: {\n type: 'string',\n },\n },\n customTagPolicyNames: {\n title: 'Custom Tag Policy Name',\n description: `The name pattern that tags must match in order to deploy to the environment.\n\n Wildcard characters will not match /. For example, to match tags that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.`,\n type: 'array',\n items: {\n type: 'string',\n },\n },\n environmentVariables: {\n title: 'Environment Variables',\n description: `Environment variables attached to the deployment environment`,\n type: 'object',\n },\n secrets: {\n title: 'Deployment Secrets',\n description: `Secrets attached to the deployment environment`,\n type: 'object',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n waitTimer: {\n title: 'Wait Timer',\n type: 'integer',\n description:\n 'The time to wait before creating or updating the environment (in milliseconds)',\n },\n preventSelfReview: {\n title: 'Prevent Self Review',\n type: 'boolean',\n description: 'Whether to prevent self-review for this environment',\n },\n reviewers: {\n title: 'Reviewers',\n type: 'array',\n description:\n 'Reviewers for this environment. Must be a list of Backstage entity references.',\n items: {\n type: 'string',\n },\n },\n },\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 const { token } = (await auth?.getPluginRequestToken({\n onBehalfOf: await ctx.getInitiatorCredentials(),\n targetPluginId: 'catalog',\n })) ?? { token: ctx.secrets?.backstageToken };\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 token: providedToken,\n host,\n owner,\n repo,\n });\n\n const client = new Octokit(octokitOptions);\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\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 catalogClient?.getEntitiesByRefs(\n {\n entityRefs: reviewers,\n },\n {\n token,\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 user = await client.rest.users.getByUsername({\n username: reviewerEntityRef.metadata.name,\n });\n githubReviewers.push({\n type: 'User',\n id: user.data.id,\n });\n } catch (error) {\n ctx.logger.error('User not found:', error);\n }\n } else if (reviewerEntityRef?.kind === 'Group') {\n try {\n const team = await client.rest.teams.getByName({\n org: owner,\n team_slug: reviewerEntityRef.metadata.name,\n });\n githubReviewers.push({\n type: 'Team',\n id: team.data.id,\n });\n } catch (error) {\n ctx.logger.error('Team not found:', error);\n }\n }\n }\n }\n\n await client.rest.repos.createOrUpdateEnvironment({\n owner: owner,\n repo: repo,\n environment_name: name,\n deployment_branch_policy: deploymentBranchPolicy ?? null,\n wait_timer: waitTimer ?? 0,\n prevent_self_review: preventSelfReview ?? false,\n reviewers: githubReviewers.length ? githubReviewers : null,\n });\n\n if (customBranchPolicyNames) {\n for (const item of customBranchPolicyNames) {\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 if (customTagPolicyNames) {\n for (const item of customTagPolicyNames) {\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 for (const [key, value] of Object.entries(environmentVariables ?? {})) {\n await client.rest.actions.createEnvironmentVariable({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n name: key,\n value,\n });\n }\n\n if (secrets) {\n const publicKeyResponse =\n await client.rest.actions.getEnvironmentPublicKey({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKeyResponse.data.key,\n Sodium.base64_variants.ORIGINAL,\n );\n for (const [key, value] of Object.entries(secrets)) {\n const binarySecret = Sodium.from_string(value);\n const encryptedBinarySecret = Sodium.crypto_box_seal(\n binarySecret,\n binaryKey,\n );\n const encryptedBase64Secret = Sodium.to_base64(\n encryptedBinarySecret,\n Sodium.base64_variants.ORIGINAL,\n );\n\n await client.rest.actions.createOrUpdateEnvironmentSecret({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n secret_name: key,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyResponse.data.key_id,\n });\n }\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAmCO,SAAS,8BAA8B,OAI3C,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,aAAe,EAAA,IAAA,EAAS,GAAA,OAAA;AAG9C,EAAA,OAAOA,yCAeJ,CAAA;AAAA,IACD,EAAI,EAAA,2BAAA;AAAA,IACJ,WAAa,EAAA,iCAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAA,EAAW,MAAM,CAAA;AAAA,QAC5B,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WAAa,EAAA,CAAA,gJAAA,CAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,kBAAA;AAAA,YACP,WAAa,EAAA,CAAA,4CAAA,CAAA;AAAA,YACb,IAAM,EAAA;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AAA,SAAA;AAAA,YACnC,qBAAA;AAAA,YACAA,wBAAO,eAAgB,CAAA;AAAA,WACzB;AAEA,UAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,+BAAgC,CAAA;AAAA,YACxD,aAAA,EAAe,WAAW,IAAK,CAAA,EAAA;AAAA,YAC/B,KAAA;AAAA,YACA,IAAA;AAAA,YACA,gBAAkB,EAAA,IAAA;AAAA,YAClB,WAAa,EAAA,GAAA;AAAA,YACb,eAAiB,EAAA,qBAAA;AAAA,YACjB,MAAA,EAAQ,kBAAkB,IAAK,CAAA;AAAA,WAChC,CAAA;AAAA;AACH;AACF;AACF,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 { CatalogApi } from '@backstage/catalog-client';\nimport { Entity } from '@backstage/catalog-model';\nimport { AuthService } from '@backstage/backend-plugin-api';\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 catalogClient?: CatalogApi;\n auth?: AuthService;\n}) {\n const { integrations, catalogClient, auth } = 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 repoUrl: string;\n name: string;\n deploymentBranchPolicy?: {\n protected_branches: boolean;\n custom_branch_policies: boolean;\n };\n customBranchPolicyNames?: string[];\n customTagPolicyNames?: string[];\n environmentVariables?: { [key: string]: string };\n secrets?: { [key: string]: string };\n token?: string;\n waitTimer?: number;\n preventSelfReview?: boolean;\n reviewers?: string[];\n }>({\n id: 'github:environment:create',\n description: 'Creates Deployment Environments',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'name'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\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 type: 'string',\n },\n name: {\n title: 'Environment Name',\n description: `Name of the deployment environment to create`,\n type: 'string',\n },\n deploymentBranchPolicy: {\n title: 'Deployment Branch Policy',\n description:\n 'The type of deployment branch policy for this environment. To allow all branches to deploy, set to `null`.',\n type: 'object',\n required: ['protected_branches', 'custom_branch_policies'],\n properties: {\n protected_branches: {\n title: 'Protected Branches',\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 type: 'boolean',\n },\n custom_branch_policies: {\n title: 'Custom Branch Policies',\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 type: 'boolean',\n },\n },\n },\n customBranchPolicyNames: {\n title: 'Custom Branch Policy Name',\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 type: 'array',\n items: {\n type: 'string',\n },\n },\n customTagPolicyNames: {\n title: 'Custom Tag Policy Name',\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 type: 'array',\n items: {\n type: 'string',\n },\n },\n environmentVariables: {\n title: 'Environment Variables',\n description: `Environment variables attached to the deployment environment`,\n type: 'object',\n },\n secrets: {\n title: 'Deployment Secrets',\n description: `Secrets attached to the deployment environment`,\n type: 'object',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n waitTimer: {\n title: 'Wait Timer',\n type: 'integer',\n description:\n 'The time to wait before creating or updating the environment (in milliseconds)',\n },\n preventSelfReview: {\n title: 'Prevent Self Review',\n type: 'boolean',\n description: 'Whether to prevent self-review for this environment',\n },\n reviewers: {\n title: 'Reviewers',\n type: 'array',\n description:\n 'Reviewers for this environment. Must be a list of Backstage entity references.',\n items: {\n type: 'string',\n },\n },\n },\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 const { token } = (await auth?.getPluginRequestToken({\n onBehalfOf: await ctx.getInitiatorCredentials(),\n targetPluginId: 'catalog',\n })) ?? { token: ctx.secrets?.backstageToken };\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 token: providedToken,\n host,\n owner,\n repo,\n });\n\n const client = new Octokit(octokitOptions);\n const repository = await client.rest.repos.get({\n owner: owner,\n repo: repo,\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 catalogClient?.getEntitiesByRefs(\n {\n entityRefs: reviewers,\n },\n {\n token,\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 user = await client.rest.users.getByUsername({\n username: reviewerEntityRef.metadata.name,\n });\n githubReviewers.push({\n type: 'User',\n id: user.data.id,\n });\n } catch (error) {\n ctx.logger.error('User not found:', error);\n }\n } else if (reviewerEntityRef?.kind === 'Group') {\n try {\n const team = await client.rest.teams.getByName({\n org: owner,\n team_slug: reviewerEntityRef.metadata.name,\n });\n githubReviewers.push({\n type: 'Team',\n id: team.data.id,\n });\n } catch (error) {\n ctx.logger.error('Team not found:', error);\n }\n }\n }\n }\n\n await client.rest.repos.createOrUpdateEnvironment({\n owner: owner,\n repo: repo,\n environment_name: name,\n deployment_branch_policy: deploymentBranchPolicy ?? null,\n wait_timer: waitTimer ?? 0,\n prevent_self_review: preventSelfReview ?? false,\n reviewers: githubReviewers.length ? githubReviewers : null,\n });\n\n if (customBranchPolicyNames) {\n for (const item of customBranchPolicyNames) {\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 if (customTagPolicyNames) {\n for (const item of customTagPolicyNames) {\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 for (const [key, value] of Object.entries(environmentVariables ?? {})) {\n await client.rest.actions.createEnvironmentVariable({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n name: key,\n value,\n });\n }\n\n if (secrets) {\n const publicKeyResponse =\n await client.rest.actions.getEnvironmentPublicKey({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n });\n\n await Sodium.ready;\n const binaryKey = Sodium.from_base64(\n publicKeyResponse.data.key,\n Sodium.base64_variants.ORIGINAL,\n );\n for (const [key, value] of Object.entries(secrets)) {\n const binarySecret = Sodium.from_string(value);\n const encryptedBinarySecret = Sodium.crypto_box_seal(\n binarySecret,\n binaryKey,\n );\n const encryptedBase64Secret = Sodium.to_base64(\n encryptedBinarySecret,\n Sodium.base64_variants.ORIGINAL,\n );\n\n await client.rest.actions.createOrUpdateEnvironmentSecret({\n repository_id: repository.data.id,\n owner: owner,\n repo: repo,\n environment_name: name,\n secret_name: key,\n encrypted_value: encryptedBase64Secret,\n key_id: publicKeyResponse.data.key_id,\n });\n }\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit","Sodium"],"mappings":";;;;;;;;;;;;;AAmCO,SAAS,8BAA8B,OAI3C,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,aAAe,EAAA,IAAA,EAAS,GAAA,OAAA;AAG9C,EAAA,OAAOA,yCAeJ,CAAA;AAAA,IACD,EAAI,EAAA,2BAAA;AAAA,IACJ,WAAa,EAAA,iCAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAA,EAAW,MAAM,CAAA;AAAA,QAC5B,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,kBAAA;AAAA,YACP,WAAa,EAAA,CAAA,4CAAA,CAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;A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AgB,CAAA;AAAA,WACzB;AAEA,UAAM,MAAA,MAAA,CAAO,IAAK,CAAA,OAAA,CAAQ,+BAAgC,CAAA;AAAA,YACxD,aAAA,EAAe,WAAW,IAAK,CAAA,EAAA;AAAA,YAC/B,KAAA;AAAA,YACA,IAAA;AAAA,YACA,gBAAkB,EAAA,IAAA;AAAA,YAClB,WAAa,EAAA,GAAA;AAAA,YACb,eAAiB,EAAA,qBAAA;AAAA,YACjB,MAAA,EAAQ,kBAAkB,IAAK,CAAA;AAAA,WAChC,CAAA;AAAA;AACH;AACF;AACF,GACD,CAAA;AACH;;;;"}
@@ -19,7 +19,7 @@ function createGithubIssuesLabelAction(options) {
19
19
  properties: {
20
20
  repoUrl: {
21
21
  title: "Repository Location",
22
- description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,
22
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username",
23
23
  type: "string"
24
24
  },
25
25
  number: {
@@ -38,7 +38,7 @@ function createGithubIssuesLabelAction(options) {
38
38
  token: {
39
39
  title: "Authentication Token",
40
40
  type: "string",
41
- description: "The GITHUB_TOKEN to use for authorization to GitHub"
41
+ description: "The `GITHUB_TOKEN` to use for authorization to GitHub"
42
42
  }
43
43
  }
44
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"githubIssuesLabel.cjs.js","sources":["../../src/actions/githubIssuesLabel.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesLabel.examples';\n\n/**\n * Adds labels to a pull request or issue on GitHub\n * @public\n */\nexport function createGithubIssuesLabelAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n number: number;\n labels: string[];\n token?: string;\n }>({\n id: 'github:issues:label',\n description: 'Adds labels to a pull request or issue on GitHub.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'number', 'labels'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,\n type: 'string',\n },\n number: {\n title: 'Pull Request or issue number',\n description: 'The pull request or issue number to add labels to',\n type: 'number',\n },\n labels: {\n title: 'Labels',\n description: 'The labels to add to the pull request or issue',\n type: 'array',\n items: {\n type: 'string',\n },\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 { repoUrl, number, labels, token: providedToken } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const client = new Octokit(\n await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n }),\n );\n\n try {\n await client.rest.issues.addLabels({\n owner,\n repo,\n issue_number: number,\n labels,\n });\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: adding labels to issue: '${number}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Octokit","getOctokitOptions","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAKJ,CAAA;AAAA,IACD,EAAI,EAAA,qBAAA;AAAA,IACJ,WAAa,EAAA,mDAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAU,EAAA,CAAC,SAAW,EAAA,QAAA,EAAU,QAAQ,CAAA;AAAA,QACxC,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WAAa,EAAA,CAAA,4IAAA,CAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,8BAAA;AAAA,YACP,WAAa,EAAA,mDAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,QAAA;AAAA,YACP,WAAa,EAAA,gDAAA;AAAA,YACb,IAAM,EAAA,OAAA;AAAA,YACN,KAAO,EAAA;AAAA,cACL,IAAM,EAAA;AAAA;AACR,WACF;AAAA,UACA,KAAO,EAAA;AAAA,YACL,KAAO,EAAA,sBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA;AAAA;AACf;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,EAAE,OAAS,EAAA,MAAA,EAAQ,QAAQ,KAAO,EAAA,aAAA,KAAkB,GAAI,CAAA,KAAA;AAE9D,MAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,MAAS,GAAAC,iCAAA,CAAa,SAAS,YAAY,CAAA;AAChE,MAAA,GAAA,CAAI,OAAO,IAAK,CAAA,CAAA,iBAAA,EAAoB,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAE,CAAA,CAAA;AAElE,MAAA,IAAI,CAAC,KAAO,EAAA;AACV,QAAM,MAAA,IAAIC,kBAAW,8CAA8C,CAAA;AAAA;AAGrE,MAAA,MAAM,SAAS,IAAIC,eAAA;AAAA,QACjB,MAAMC,sBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB,IAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAO,EAAA;AAAA,SACR;AAAA,OACH;AAEA,MAAI,IAAA;AACF,QAAM,MAAA,MAAA,CAAO,IAAK,CAAA,MAAA,CAAO,SAAU,CAAA;AAAA,UACjC,KAAA;AAAA,UACA,IAAA;AAAA,UACA,YAAc,EAAA,MAAA;AAAA,UACd;AAAA,SACD,CAAA;AAAA,eACM,CAAG,EAAA;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,UACT,oCAAoC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SAC9E;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubIssuesLabel.cjs.js","sources":["../../src/actions/githubIssuesLabel.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubIssuesLabel.examples';\n\n/**\n * Adds labels to a pull request or issue on GitHub\n * @public\n */\nexport function createGithubIssuesLabelAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n number: number;\n labels: string[];\n token?: string;\n }>({\n id: 'github:issues:label',\n description: 'Adds labels to a pull request or issue on GitHub.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'number', 'labels'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n type: 'string',\n },\n number: {\n title: 'Pull Request or issue number',\n description: 'The pull request or issue number to add labels to',\n type: 'number',\n },\n labels: {\n title: 'Labels',\n description: 'The labels to add to the pull request or issue',\n type: 'array',\n items: {\n type: 'string',\n },\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const { repoUrl, number, labels, token: providedToken } = ctx.input;\n\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const client = new Octokit(\n await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n }),\n );\n\n try {\n await client.rest.issues.addLabels({\n owner,\n repo,\n issue_number: number,\n labels,\n });\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: adding labels to issue: '${number}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Octokit","getOctokitOptions","assertError"],"mappings":";;;;;;;;AAiCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAKJ,CAAA;AAAA,IACD,EAAI,EAAA,qBAAA;AAAA,IACJ,WAAa,EAAA,mDAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAU,EAAA,CAAC,SAAW,EAAA,QAAA,EAAU,QAAQ,CAAA;AAAA,QACxC,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,8IAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,8BAAA;AAAA,YACP,WAAa,EAAA,mDAAA;AAAA,YACb,IAAM,EAAA;AAAA,WACR;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,QAAA;AAAA,YACP,WAAa,EAAA,gDAAA;AAAA,YACb,IAAM,EAAA,OAAA;AAAA,YACN,KAAO,EAAA;AAAA,cACL,IAAM,EAAA;AAAA;AACR,WACF;AAAA,UACA,KAAO,EAAA;AAAA,YACL,KAAO,EAAA,sBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WACE,EAAA;AAAA;AACJ;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,EAAE,OAAS,EAAA,MAAA,EAAQ,QAAQ,KAAO,EAAA,aAAA,KAAkB,GAAI,CAAA,KAAA;AAE9D,MAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,MAAS,GAAAC,iCAAA,CAAa,SAAS,YAAY,CAAA;AAChE,MAAA,GAAA,CAAI,OAAO,IAAK,CAAA,CAAA,iBAAA,EAAoB,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAE,CAAA,CAAA;AAElE,MAAA,IAAI,CAAC,KAAO,EAAA;AACV,QAAM,MAAA,IAAIC,kBAAW,8CAA8C,CAAA;AAAA;AAGrE,MAAA,MAAM,SAAS,IAAIC,eAAA;AAAA,QACjB,MAAMC,sBAAkB,CAAA;AAAA,UACtB,YAAA;AAAA,UACA,mBAAqB,EAAA,yBAAA;AAAA,UACrB,IAAA;AAAA,UACA,KAAA;AAAA,UACA,IAAA;AAAA,UACA,KAAO,EAAA;AAAA,SACR;AAAA,OACH;AAEA,MAAI,IAAA;AACF,QAAM,MAAA,MAAA,CAAO,IAAK,CAAA,MAAA,CAAO,SAAU,CAAA;AAAA,UACjC,KAAA;AAAA,UACA,IAAA;AAAA,UACA,YAAc,EAAA,MAAA;AAAA,UACd;AAAA,SACD,CAAA;AAAA,eACM,CAAG,EAAA;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,UACT,oCAAoC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SAC9E;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
@@ -19,23 +19,28 @@ function createGithubPagesEnableAction(options) {
19
19
  properties: {
20
20
  repoUrl: {
21
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`,
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
23
  type: "string"
24
24
  },
25
25
  buildType: {
26
26
  title: "Build Type",
27
27
  type: "string",
28
- description: 'The GitHub Pages build type - "legacy" or "workflow". Default is "workflow'
28
+ default: "workflow",
29
+ description: "The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`",
30
+ enum: ["legacy", "workflow"]
29
31
  },
30
32
  sourceBranch: {
31
33
  title: "Source Branch",
32
34
  type: "string",
35
+ default: "main",
33
36
  description: 'The GitHub Pages source branch. Default is "main"'
34
37
  },
35
38
  sourcePath: {
36
39
  title: "Source Path",
37
40
  type: "string",
38
- description: 'The GitHub Pages source path - "/" or "/docs". Default is "/"'
41
+ default: "/",
42
+ description: 'The GitHub Pages source path - "/" or "/docs". Default is "/"',
43
+ enum: ["/", "/docs"]
39
44
  },
40
45
  token: {
41
46
  title: "Authorization Token",
@@ -1 +1 @@
1
- {"version":3,"file":"githubPagesEnable.cjs.js","sources":["../../src/actions/githubPagesEnable.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 GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './githubPagesEnable.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Creates a new action that enables GitHub Pages for a repository.\n *\n * @public\n */\nexport function createGithubPagesEnableAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n buildType?: 'legacy' | 'workflow';\n sourceBranch?: string;\n sourcePath?: '/' | '/docs';\n token?: string;\n }>({\n id: 'github:pages:enable',\n examples,\n description: 'Enables GitHub Pages for a repository.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\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 buildType: {\n title: 'Build Type',\n type: 'string',\n description:\n 'The GitHub Pages build type - \"legacy\" or \"workflow\". Default is \"workflow',\n },\n sourceBranch: {\n title: 'Source Branch',\n type: 'string',\n description: 'The GitHub Pages source branch. Default is \"main\"',\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n description:\n 'The GitHub Pages source path - \"/\" or \"/docs\". Default is \"/\"',\n },\n token: {\n title: 'Authorization Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n buildType = 'workflow',\n sourceBranch = 'main',\n sourcePath = '/',\n token: providedToken,\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 credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit(octokitOptions);\n\n ctx.logger.info(\n `Attempting to enable GitHub Pages for ${owner}/${repo} with \"${buildType}\" build type, on source branch \"${sourceBranch}\" and source path \"${sourcePath}\"`,\n );\n\n await client.request('POST /repos/{owner}/{repo}/pages', {\n owner: owner,\n repo: repo,\n build_type: buildType,\n source: {\n branch: sourceBranch,\n path: sourcePath,\n },\n headers: {\n 'X-GitHub-Api-Version': '2022-11-28',\n },\n });\n\n ctx.logger.info('Completed enabling GitHub Pages');\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAkCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAA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,CAAC,KAAO,EAAA;AACV,QAAM,MAAA,IAAIC,kBAAW,8CAA8C,CAAA;AAAA;AAGrE,MAAM,MAAA,cAAA,GAAiB,MAAMC,sBAAkB,CAAA;AAAA,QAC7C,YAAA;AAAA,QACA,mBAAqB,EAAA,yBAAA;AAAA,QACrB,KAAO,EAAA,aAAA;AAAA,QACP,IAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAM,MAAA,MAAA,GAAS,IAAIC,eAAA,CAAQ,cAAc,CAAA;AAEzC,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,QACT,CAAA,sCAAA,EAAyC,KAAK,CAAI,CAAA,EAAA,IAAI,UAAU,SAAS,CAAA,gCAAA,EAAmC,YAAY,CAAA,mBAAA,EAAsB,UAAU,CAAA,CAAA;AAAA,OAC1J;AAEA,MAAM,MAAA,MAAA,CAAO,QAAQ,kCAAoC,EAAA;AAAA,QACvD,KAAA;AAAA,QACA,IAAA;AAAA,QACA,UAAY,EAAA,SAAA;AAAA,QACZ,MAAQ,EAAA;AAAA,UACN,MAAQ,EAAA,YAAA;AAAA,UACR,IAAM,EAAA;AAAA,SACR;AAAA,QACA,OAAS,EAAA;AAAA,UACP,sBAAwB,EAAA;AAAA;AAC1B,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,KAAK,iCAAiC,CAAA;AAAA;AACnD,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubPagesEnable.cjs.js","sources":["../../src/actions/githubPagesEnable.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 GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Octokit } from 'octokit';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './githubPagesEnable.examples';\nimport { getOctokitOptions } from '../util';\n\n/**\n * Creates a new action that enables GitHub Pages for a repository.\n *\n * @public\n */\nexport function createGithubPagesEnableAction(options: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, githubCredentialsProvider } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n buildType?: 'legacy' | 'workflow';\n sourceBranch?: string;\n sourcePath?: '/' | '/docs';\n token?: string;\n }>({\n id: 'github:pages:enable',\n examples,\n description: 'Enables GitHub Pages for a repository.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\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 type: 'string',\n },\n buildType: {\n title: 'Build Type',\n type: 'string',\n default: 'workflow',\n description:\n 'The GitHub Pages build type - `legacy` or `workflow`. Default is `workflow`',\n enum: ['legacy', 'workflow'],\n },\n sourceBranch: {\n title: 'Source Branch',\n type: 'string',\n default: 'main',\n description: 'The GitHub Pages source branch. Default is \"main\"',\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n default: '/',\n description:\n 'The GitHub Pages source path - \"/\" or \"/docs\". Default is \"/\"',\n enum: ['/', '/docs'],\n },\n token: {\n title: 'Authorization Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n buildType = 'workflow',\n sourceBranch = 'main',\n sourcePath = '/',\n token: providedToken,\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 credentialsProvider: githubCredentialsProvider,\n token: providedToken,\n host,\n owner,\n repo,\n });\n const client = new Octokit(octokitOptions);\n\n ctx.logger.info(\n `Attempting to enable GitHub Pages for ${owner}/${repo} with \"${buildType}\" build type, on source branch \"${sourceBranch}\" and source path \"${sourcePath}\"`,\n );\n\n await client.request('POST /repos/{owner}/{repo}/pages', {\n owner: owner,\n repo: repo,\n build_type: buildType,\n source: {\n branch: sourceBranch,\n path: sourcePath,\n },\n headers: {\n 'X-GitHub-Api-Version': '2022-11-28',\n },\n });\n\n ctx.logger.info('Completed enabling GitHub Pages');\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getOctokitOptions","Octokit"],"mappings":";;;;;;;;AAkCO,SAAS,8BAA8B,OAG3C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,yBAAA,EAA8B,GAAA,OAAA;AAEpD,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,qBAAA;AAAA,cACJC,mCAAA;AAAA,IACA,WAAa,EAAA,wCAAA;AAAA,IACb,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,QACpB,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,WACE,EAAA,kJAAA;AAAA,YACF,IAAM,EAAA;AAAA,WACR;AAAA,UACA,SAAW,EAAA;AAAA,YACT,KAAO,EAAA,YAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,OAAS,EAAA,UAAA;AAAA,YACT,WACE,EAAA,6EAAA;AAAA,YACF,IAAA,EAAM,CAAC,QAAA,EAAU,UAAU;AAAA,WAC7B;AAAA,UACA,YAAc,EAAA;AAAA,YACZ,KAAO,EAAA,eAAA;AAAA,Y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CAAA,CAAA;AAAA,OAC1J;AAEA,MAAM,MAAA,MAAA,CAAO,QAAQ,kCAAoC,EAAA;AAAA,QACvD,KAAA;AAAA,QACA,IAAA;AAAA,QACA,UAAY,EAAA,SAAA;AAAA,QACZ,MAAQ,EAAA;AAAA,UACN,MAAQ,EAAA,YAAA;AAAA,UACR,IAAM,EAAA;AAAA,SACR;AAAA,QACA,OAAS,EAAA;AAAA,UACP,sBAAwB,EAAA;AAAA;AAC1B,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,KAAK,iCAAiC,CAAA;AAAA;AACnD,GACD,CAAA;AACH;;;;"}
@@ -55,7 +55,7 @@ const createPublishGithubPullRequestAction = (options) => {
55
55
  properties: {
56
56
  repoUrl: {
57
57
  title: "Repository Location",
58
- description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,
58
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username",
59
59
  type: "string"
60
60
  },
61
61
  branchName: {
@@ -66,7 +66,7 @@ const createPublishGithubPullRequestAction = (options) => {
66
66
  targetBranchName: {
67
67
  type: "string",
68
68
  title: "Target Branch Name",
69
- description: "The target branch name of the merge request"
69
+ description: "The target branch name of the pull request"
70
70
  },
71
71
  title: {
72
72
  type: "string",
@@ -132,12 +132,12 @@ const createPublishGithubPullRequestAction = (options) => {
132
132
  gitAuthorName: {
133
133
  type: "string",
134
134
  title: "Default Author Name",
135
- description: "Sets the default author name for the commit. The default value is the authenticated user or 'Scaffolder'"
135
+ description: "Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`"
136
136
  },
137
137
  gitAuthorEmail: {
138
138
  type: "string",
139
139
  title: "Default Author Email",
140
- description: "Sets the default author email for the commit. The default value is the authenticated user or 'scaffolder@backstage.io'"
140
+ description: "Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`"
141
141
  },
142
142
  forceEmptyGitAuthor: {
143
143
  type: "boolean",
@@ -1 +1 @@
1
- {"version":3,"file":"githubPullRequest.cjs.js","sources":["../../src/actions/githubPullRequest.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 path from 'path';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { CustomErrorBase, InputError } from '@backstage/errors';\nimport { createPullRequest } from 'octokit-plugin-create-pull-request';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubPullRequest.examples';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\n\nexport type Encoding = 'utf-8' | 'base64';\n\nclass GithubResponseError extends CustomErrorBase {}\n\nexport const defaultClientFactory: CreateGithubPullRequestActionOptions['clientFactory'] =\n async ({\n integrations,\n githubCredentialsProvider,\n owner,\n repo,\n host = 'github.com',\n token: providedToken,\n }) => {\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const OctokitPR = Octokit.plugin(createPullRequest);\n return new OctokitPR({\n ...octokitOptions,\n ...{ throttle: { enabled: false } },\n });\n };\n\n/**\n * The options passed to {@link createPublishGithubPullRequestAction} method\n * @public\n */\nexport interface CreateGithubPullRequestActionOptions {\n /**\n * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.\n */\n integrations: ScmIntegrationRegistry;\n /**\n * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.\n */\n githubCredentialsProvider?: GithubCredentialsProvider;\n /**\n * A method to return the Octokit client with the Pull Request Plugin.\n */\n clientFactory?: (input: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n host: string;\n owner: string;\n repo: string;\n token?: string;\n }) => Promise<\n Octokit & {\n createPullRequest(options: createPullRequest.Options): Promise<{\n data: {\n html_url: string;\n number: number;\n base: {\n ref: string;\n };\n };\n } | null>;\n }\n >;\n /**\n * An instance of {@link @backstage/config#Config} that will be used in the action.\n */\n config?: Config;\n}\n\ntype GithubPullRequest = {\n owner: string;\n repo: string;\n number: number;\n};\n\n/**\n * Creates a Github Pull Request action.\n * @public\n */\nexport const createPublishGithubPullRequestAction = (\n options: CreateGithubPullRequestActionOptions,\n) => {\n const {\n integrations,\n githubCredentialsProvider,\n clientFactory = defaultClientFactory,\n config,\n } = options;\n\n return createTemplateAction<{\n title: string;\n branchName: string;\n targetBranchName?: string;\n description: string;\n repoUrl: string;\n draft?: boolean;\n targetPath?: string;\n sourcePath?: string;\n token?: string;\n reviewers?: string[];\n teamReviewers?: string[];\n commitMessage?: string;\n update?: boolean;\n forceFork?: boolean;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n forceEmptyGitAuthor?: boolean;\n createWhenEmpty?: boolean;\n }>({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n required: ['repoUrl', 'title', 'description', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,\n type: 'string',\n },\n branchName: {\n type: 'string',\n title: 'Branch Name',\n description: 'The name for the branch',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the merge request',\n },\n title: {\n type: 'string',\n title: 'Pull Request Name',\n description: 'The name for the pull request',\n },\n description: {\n type: 'string',\n title: 'Pull Request Description',\n description: 'The description of the pull request',\n },\n draft: {\n type: 'boolean',\n title: 'Create as Draft',\n description: 'Create a draft pull request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n reviewers: {\n title: 'Pull Request Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The users that will be added as reviewers to the pull request',\n },\n teamReviewers: {\n title: 'Pull Request Team Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The teams that will be added as reviewers to the pull request',\n },\n commitMessage: {\n type: 'string',\n title: 'Commit Message',\n description: 'The commit message for the pull request commit',\n },\n update: {\n type: 'boolean',\n title: 'Update',\n description: 'Update pull request if already exists',\n },\n forceFork: {\n type: 'boolean',\n title: 'Force Fork',\n description: 'Create pull request from a fork',\n },\n gitAuthorName: {\n type: 'string',\n title: 'Default Author Name',\n description:\n \"Sets the default author name for the commit. The default value is the authenticated user or 'Scaffolder'\",\n },\n gitAuthorEmail: {\n type: 'string',\n title: 'Default Author Email',\n description:\n \"Sets the default author email for the commit. The default value is the authenticated user or 'scaffolder@backstage.io'\",\n },\n forceEmptyGitAuthor: {\n type: 'boolean',\n title: 'Force Empty Git Author',\n description:\n 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',\n },\n createWhenEmpty: {\n type: 'boolean',\n title: 'Create When Empty',\n description:\n 'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',\n },\n },\n },\n output: {\n required: [],\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n remoteUrl: {\n type: 'string',\n title: 'Pull Request URL',\n description: 'Link to the pull request in Github',\n },\n pullRequestNumber: {\n type: 'number',\n title: 'Pull Request Number',\n description: 'The pull request number',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n createWhenEmpty,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries(\n directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\n createWhenEmpty,\n };\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ??\n config?.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ??\n config?.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n const response = await client.createPullRequest(createOptions);\n\n if (createWhenEmpty === false && !response) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!response) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = response.data.number;\n if (reviewers || teamReviewers) {\n const pullRequest = { owner, repo, number: pullRequestNumber };\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n );\n }\n\n const targetBranch = response.data.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', response.data.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n ) {\n try {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers ? [...new Set(teamReviewers)] : undefined,\n });\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,4BAA4BA,sBAAgB,CAAA;AAAC;AAE5C,MAAM,uBACX,OAAO;AAAA,EACL,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAO,GAAA,YAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAM,KAAA;AACJ,EAAM,MAAA,cAAA,GAAiB,MAAMC,sBAAkB,CAAA;AAAA,IAC7C,YAAA;AAAA,IACA,mBAAqB,EAAA,yBAAA;AAAA,IACrB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAO,EAAA;AAAA,GACR,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,eAAQ,CAAA,MAAA,CAAOC,gDAAiB,CAAA;AAClD,EAAA,OAAO,IAAI,SAAU,CAAA;AAAA,IACnB,GAAG,cAAA;AAAA,IACH,GAAG,EAAE,QAAA,EAAU,EAAE,OAAA,EAAS,OAAQ;AAAA,GACnC,CAAA;AACH;AAsDW,MAAA,oCAAA,GAA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,QAAI,GAAA,CAAA,MAAA,CAAO,qBAAqB,iBAAiB,CAAA;AAAA,eAC1C,CAAG,EAAA;AACV,QAAM,MAAA,IAAI,mBAAoB,CAAA,8BAAA,EAAgC,CAAC,CAAA;AAAA;AACjE;AACF,GACD,CAAA;AAED,EAAA,eAAe,6BACb,CAAA,EAAA,EACA,SACA,EAAA,aAAA,EACA,QACA,MACA,EAAA;AACA,IAAI,IAAA;AACF,MAAA,MAAM,MAAS,GAAA,MAAM,MAAO,CAAA,IAAA,CAAK,MAAM,gBAAiB,CAAA;AAAA,QACtD,OAAO,EAAG,CAAA,KAAA;AAAA,QACV,MAAM,EAAG,CAAA,IAAA;AAAA,QACT,aAAa,EAAG,CAAA,MAAA;AAAA,QAChB,SAAA;AAAA,QACA,cAAA,EAAgB,gBAAgB,CAAC,GAAG,IAAI,GAAI,CAAA,aAAa,CAAC,CAAI,GAAA,KAAA;AAAA,OAC/D,CAAA;AACD,MAAA,MAAM,aAAa,MAAO,CAAA,IAAA,CAAK,mBAAqB,EAAA,IAAA,CAAK,IAAI,CAAK,IAAA,EAAA;AAClE,MAAA,MAAM,aAAa,MAAO,CAAA,IAAA,CAAK,eAAiB,EAAA,IAAA,CAAK,IAAI,CAAK,IAAA,EAAA;AAC9D,MAAO,MAAA,CAAA,IAAA;AAAA,QACL,gBAAgB,UAAU,CAAA,aAAA,EAAgB,UAAU,CAAA,+BAAA,EAAkC,GAAG,MAAM,CAAA;AAAA,OACjG;AAAA,aACO,CAAG,EAAA;AACV,MAAO,MAAA,CAAA,KAAA;AAAA,QACL,CAAA,8CAAA,EAAiD,GAAG,MAAM,CAAA,CAAA;AAAA,QAC1D;AAAA,OACF;AAAA;AACF;AAEJ;;;;;"}
1
+ {"version":3,"file":"githubPullRequest.cjs.js","sources":["../../src/actions/githubPullRequest.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 path from 'path';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { CustomErrorBase, InputError } from '@backstage/errors';\nimport { createPullRequest } from 'octokit-plugin-create-pull-request';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubPullRequest.examples';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\n\nexport type Encoding = 'utf-8' | 'base64';\n\nclass GithubResponseError extends CustomErrorBase {}\n\nexport const defaultClientFactory: CreateGithubPullRequestActionOptions['clientFactory'] =\n async ({\n integrations,\n githubCredentialsProvider,\n owner,\n repo,\n host = 'github.com',\n token: providedToken,\n }) => {\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const OctokitPR = Octokit.plugin(createPullRequest);\n return new OctokitPR({\n ...octokitOptions,\n ...{ throttle: { enabled: false } },\n });\n };\n\n/**\n * The options passed to {@link createPublishGithubPullRequestAction} method\n * @public\n */\nexport interface CreateGithubPullRequestActionOptions {\n /**\n * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.\n */\n integrations: ScmIntegrationRegistry;\n /**\n * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.\n */\n githubCredentialsProvider?: GithubCredentialsProvider;\n /**\n * A method to return the Octokit client with the Pull Request Plugin.\n */\n clientFactory?: (input: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n host: string;\n owner: string;\n repo: string;\n token?: string;\n }) => Promise<\n Octokit & {\n createPullRequest(options: createPullRequest.Options): Promise<{\n data: {\n html_url: string;\n number: number;\n base: {\n ref: string;\n };\n };\n } | null>;\n }\n >;\n /**\n * An instance of {@link @backstage/config#Config} that will be used in the action.\n */\n config?: Config;\n}\n\ntype GithubPullRequest = {\n owner: string;\n repo: string;\n number: number;\n};\n\n/**\n * Creates a Github Pull Request action.\n * @public\n */\nexport const createPublishGithubPullRequestAction = (\n options: CreateGithubPullRequestActionOptions,\n) => {\n const {\n integrations,\n githubCredentialsProvider,\n clientFactory = defaultClientFactory,\n config,\n } = options;\n\n return createTemplateAction<{\n title: string;\n branchName: string;\n targetBranchName?: string;\n description: string;\n repoUrl: string;\n draft?: boolean;\n targetPath?: string;\n sourcePath?: string;\n token?: string;\n reviewers?: string[];\n teamReviewers?: string[];\n commitMessage?: string;\n update?: boolean;\n forceFork?: boolean;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n forceEmptyGitAuthor?: boolean;\n createWhenEmpty?: boolean;\n }>({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n required: ['repoUrl', 'title', 'description', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description:\n 'Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the repository name and `owner` is an organization or username',\n type: 'string',\n },\n branchName: {\n type: 'string',\n title: 'Branch Name',\n description: 'The name for the branch',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the pull request',\n },\n title: {\n type: 'string',\n title: 'Pull Request Name',\n description: 'The name for the pull request',\n },\n description: {\n type: 'string',\n title: 'Pull Request Description',\n description: 'The description of the pull request',\n },\n draft: {\n type: 'boolean',\n title: 'Create as Draft',\n description: 'Create a draft pull request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n reviewers: {\n title: 'Pull Request Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The users that will be added as reviewers to the pull request',\n },\n teamReviewers: {\n title: 'Pull Request Team Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The teams that will be added as reviewers to the pull request',\n },\n commitMessage: {\n type: 'string',\n title: 'Commit Message',\n description: 'The commit message for the pull request commit',\n },\n update: {\n type: 'boolean',\n title: 'Update',\n description: 'Update pull request if already exists',\n },\n forceFork: {\n type: 'boolean',\n title: 'Force Fork',\n description: 'Create pull request from a fork',\n },\n gitAuthorName: {\n type: 'string',\n title: 'Default Author Name',\n description:\n 'Sets the default author name for the commit. The default value is the authenticated user or `Scaffolder`',\n },\n gitAuthorEmail: {\n type: 'string',\n title: 'Default Author Email',\n description:\n 'Sets the default author email for the commit. The default value is the authenticated user or `scaffolder@backstage.io`',\n },\n forceEmptyGitAuthor: {\n type: 'boolean',\n title: 'Force Empty Git Author',\n description:\n 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',\n },\n createWhenEmpty: {\n type: 'boolean',\n title: 'Create When Empty',\n description:\n 'Set whether to create pull request when there are no changes to commit. The default value is true. If set to false, remoteUrl is no longer a required output.',\n },\n },\n },\n output: {\n required: [],\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n remoteUrl: {\n type: 'string',\n title: 'Pull Request URL',\n description: 'Link to the pull request in Github',\n },\n pullRequestNumber: {\n type: 'number',\n title: 'Pull Request Number',\n description: 'The pull request number',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n createWhenEmpty,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries(\n directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\n createWhenEmpty,\n };\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ??\n config?.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ??\n config?.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n const response = await client.createPullRequest(createOptions);\n\n if (createWhenEmpty === false && !response) {\n ctx.logger.info('No changes to commit, pull request was not created');\n return;\n }\n\n if (!response) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = response.data.number;\n if (reviewers || teamReviewers) {\n const pullRequest = { owner, repo, number: pullRequestNumber };\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n );\n }\n\n const targetBranch = response.data.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', response.data.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n ) {\n try {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers ? [...new Set(teamReviewers)] : undefined,\n });\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,4BAA4BA,sBAAgB,CAAA;AAAC;AAE5C,MAAM,uBACX,OAAO;AAAA,EACL,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAO,GAAA,YAAA;AAAA,EACP,KAAO,EAAA;AACT,CAAM,KAAA;AACJ,EAAM,MAAA,cAAA,GAAiB,MAAMC,sBAAkB,CAAA;AAAA,IAC7C,YAAA;AAAA,IACA,mBAAqB,EAAA,yBAAA;AAAA,IACrB,IAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAO,EAAA;AAAA,GACR,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,eAAQ,CAAA,MAAA,CAAOC,gDAAiB,CAAA;AAClD,EAAA,OAAO,IAAI,SAAU,CAAA;AAAA,IACnB,GAAG,cAAA;AAAA,IACH,GAAG,EAAE,QAAA,EAAU,EAAE,OAAA,EAAS,OAAQ;AAAA,GACnC,CAAA;AACH;AAsDW,MAAA,oCAAA,GAAuC,CAClD,OACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,YAAA;AAAA,IACA,yBAAA;AAAA,IACA,aAAgB,GAAA,oBAAA;AAAA,IAChB;AAAA,GACE,GAAA,OAAA;AAEJ,EAAA,OAAOC,yCAmBJ,CAAA;AAAA,IACD,EAAI,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EACA,SACA,EAAA,aAAA,EACA,QACA,MACA,EAAA;AACA,IAAI,IAAA;AACF,MAAA,MAAM,MAAS,GAAA,MAAM,MAAO,CAAA,IAAA,CAAK,MAAM,gBAAiB,CAAA;AAAA,QACtD,OAAO,EAAG,CAAA,KAAA;AAAA,QACV,MAAM,EAAG,CAAA,IAAA;AAAA,QACT,aAAa,EAAG,CAAA,MAAA;AAAA,QAChB,SAAA;AAAA,QACA,cAAA,EAAgB,gBAAgB,CAAC,GAAG,IAAI,GAAI,CAAA,aAAa,CAAC,CAAI,GAAA,KAAA;AAAA,OAC/D,CAAA;AACD,MAAA,MAAM,aAAa,MAAO,CAAA,IAAA,CAAK,mBAAqB,EAAA,IAAA,CAAK,IAAI,CAAK,IAAA,EAAA;AAClE,MAAA,MAAM,aAAa,MAAO,CAAA,IAAA,CAAK,eAAiB,EAAA,IAAA,CAAK,IAAI,CAAK,IAAA,EAAA;AAC9D,MAAO,MAAA,CAAA,IAAA;AAAA,QACL,gBAAgB,UAAU,CAAA,aAAA,EAAgB,UAAU,CAAA,+BAAA,EAAkC,GAAG,MAAM,CAAA;AAAA,OACjG;AAAA,aACO,CAAG,EAAA;AACV,MAAO,MAAA,CAAA,KAAA;AAAA,QACL,CAAA,8CAAA,EAAiD,GAAG,MAAM,CAAA,CAAA;AAAA,QAC1D;AAAA,OACF;AAAA;AACF;AAEJ;;;;;"}
@@ -22,7 +22,7 @@ function createGithubWebhookAction(options) {
22
22
  properties: {
23
23
  repoUrl: {
24
24
  title: "Repository Location",
25
- description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
25
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username",
26
26
  type: "string"
27
27
  },
28
28
  webhookUrl: {
@@ -37,8 +37,9 @@ function createGithubWebhookAction(options) {
37
37
  },
38
38
  events: {
39
39
  title: "Triggering Events",
40
- description: "Determines what events the hook is triggered for. Default: push",
40
+ description: "Determines what events the hook is triggered for. Default: `[push]`",
41
41
  type: "array",
42
+ default: ["push"],
42
43
  oneOf: [
43
44
  {
44
45
  items: {
@@ -57,23 +58,26 @@ function createGithubWebhookAction(options) {
57
58
  active: {
58
59
  title: "Active",
59
60
  type: "boolean",
60
- description: `Determines if notifications are sent when the webhook is triggered. Default: true`
61
+ default: true,
62
+ description: "Determines if notifications are sent when the webhook is triggered. Default: `true`"
61
63
  },
62
64
  contentType: {
63
65
  title: "Content Type",
64
66
  type: "string",
65
67
  enum: ["form", "json"],
66
- description: `The media type used to serialize the payloads. The default is 'form'`
68
+ default: "form",
69
+ description: "The media type used to serialize the payloads. The default is `form`"
67
70
  },
68
71
  insecureSsl: {
69
72
  title: "Insecure SSL",
70
73
  type: "boolean",
71
- description: `Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default 'false'`
74
+ default: false,
75
+ description: "Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`"
72
76
  },
73
77
  token: {
74
78
  title: "Authentication Token",
75
79
  type: "string",
76
- description: "The GITHUB_TOKEN to use for authorization to GitHub"
80
+ description: "The `GITHUB_TOKEN` to use for authorization to GitHub"
77
81
  }
78
82
  }
79
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"githubWebhook.cjs.js","sources":["../../src/actions/githubWebhook.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { emitterEventNames } from '@octokit/webhooks';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubWebhook.examples';\n\n/**\n * Creates new action that creates a webhook for a repository on GitHub.\n * @public\n */\nexport function createGithubWebhookAction(options: {\n integrations: ScmIntegrationRegistry;\n defaultWebhookSecret?: string;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, defaultWebhookSecret, githubCredentialsProvider } =\n options;\n\n const eventNames = emitterEventNames.filter(event => !event.includes('.'));\n\n return createTemplateAction<{\n repoUrl: string;\n webhookUrl: string;\n webhookSecret?: string;\n events?: string[];\n active?: boolean;\n contentType?: 'form' | 'json';\n insecureSsl?: boolean;\n token?: string;\n }>({\n id: 'github:webhook',\n description: 'Creates webhook for a repository on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'webhookUrl'],\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 webhookUrl: {\n title: 'Webhook URL',\n description: 'The URL to which the payloads will be delivered',\n type: 'string',\n },\n webhookSecret: {\n title: 'Webhook Secret',\n description:\n 'Webhook secret value. The default can be provided internally in action creation',\n type: 'string',\n },\n events: {\n title: 'Triggering Events',\n description:\n 'Determines what events the hook is triggered for. Default: push',\n type: 'array',\n oneOf: [\n {\n items: {\n type: 'string',\n enum: eventNames,\n },\n },\n {\n items: {\n type: 'string',\n const: '*',\n },\n },\n ],\n },\n active: {\n title: 'Active',\n type: 'boolean',\n description: `Determines if notifications are sent when the webhook is triggered. Default: true`,\n },\n contentType: {\n title: 'Content Type',\n type: 'string',\n enum: ['form', 'json'],\n description: `The media type used to serialize the payloads. The default is 'form'`,\n },\n insecureSsl: {\n title: 'Insecure SSL',\n type: 'boolean',\n description: `Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default 'false'`,\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 webhookUrl,\n webhookSecret = defaultWebhookSecret,\n events = ['push'],\n active = true,\n contentType = 'form',\n insecureSsl = false,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const client = new Octokit(\n await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n }),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const insecure_ssl = insecureSsl ? '1' : '0';\n await client.rest.repos.createWebhook({\n owner,\n repo,\n config: {\n url: webhookUrl,\n content_type: contentType,\n secret: webhookSecret,\n insecure_ssl,\n },\n events,\n active,\n });\n ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["emitterEventNames","createTemplateAction","examples","parseRepoUrl","InputError","Octokit","getOctokitOptions","assertError"],"mappings":";;;;;;;;;AAkCO,SAAS,0BAA0B,OAIvC,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,oBAAsB,EAAA,yBAAA,EAC1C,GAAA,OAAA;AAEF,EAAM,MAAA,UAAA,GAAaA,2BAAkB,MAAO,CAAA,CAAA,KAAA,KAAS,CAAC,KAAM,CAAA,QAAA,CAAS,GAAG,CAAC,CAAA;AAEzE,EAAA,OAAOC,yCASJ,CAAA;AAAA,IACD,EAAI,EAAA,gBAAA;AAAA,IACJ,WAAa,EAAA,6CA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,GAAe,cAAc,GAAM,GAAA,GAAA;AACzC,QAAM,MAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,aAAc,CAAA;AAAA,UACpC,KAAA;AAAA,UACA,IAAA;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,GAAK,EAAA,UAAA;AAAA,YACL,YAAc,EAAA,WAAA;AAAA,YACd,MAAQ,EAAA,aAAA;AAAA,YACR;AAAA,WACF;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAAwB,sBAAA,CAAA,CAAA;AAAA,eACvD,CAAG,EAAA;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,UACT,2BAA2B,UAAU,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SACzE;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"githubWebhook.cjs.js","sources":["../../src/actions/githubWebhook.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { emitterEventNames } from '@octokit/webhooks';\nimport { assertError, InputError } from '@backstage/errors';\nimport { Octokit } from 'octokit';\nimport { getOctokitOptions } from '../util';\nimport { examples } from './githubWebhook.examples';\n\n/**\n * Creates new action that creates a webhook for a repository on GitHub.\n * @public\n */\nexport function createGithubWebhookAction(options: {\n integrations: ScmIntegrationRegistry;\n defaultWebhookSecret?: string;\n githubCredentialsProvider?: GithubCredentialsProvider;\n}) {\n const { integrations, defaultWebhookSecret, githubCredentialsProvider } =\n options;\n\n const eventNames = emitterEventNames.filter(event => !event.includes('.'));\n\n return createTemplateAction<{\n repoUrl: string;\n webhookUrl: string;\n webhookSecret?: string;\n events?: string[];\n active?: boolean;\n contentType?: 'form' | 'json';\n insecureSsl?: boolean;\n token?: string;\n }>({\n id: 'github:webhook',\n description: 'Creates webhook for a repository on GitHub.',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'webhookUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\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 type: 'string',\n },\n webhookUrl: {\n title: 'Webhook URL',\n description: 'The URL to which the payloads will be delivered',\n type: 'string',\n },\n webhookSecret: {\n title: 'Webhook Secret',\n description:\n 'Webhook secret value. The default can be provided internally in action creation',\n type: 'string',\n },\n events: {\n title: 'Triggering Events',\n description:\n 'Determines what events the hook is triggered for. Default: `[push]`',\n type: 'array',\n default: ['push'],\n oneOf: [\n {\n items: {\n type: 'string',\n enum: eventNames,\n },\n },\n {\n items: {\n type: 'string',\n const: '*',\n },\n },\n ],\n },\n active: {\n title: 'Active',\n type: 'boolean',\n default: true,\n description:\n 'Determines if notifications are sent when the webhook is triggered. Default: `true`',\n },\n contentType: {\n title: 'Content Type',\n type: 'string',\n enum: ['form', 'json'],\n default: 'form',\n description:\n 'The media type used to serialize the payloads. The default is `form`',\n },\n insecureSsl: {\n title: 'Insecure SSL',\n type: 'boolean',\n default: false,\n description:\n 'Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Default `false`',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The `GITHUB_TOKEN` to use for authorization to GitHub',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n webhookUrl,\n webhookSecret = defaultWebhookSecret,\n events = ['push'],\n active = true,\n contentType = 'form',\n insecureSsl = false,\n token: providedToken,\n } = ctx.input;\n\n ctx.logger.info(`Creating webhook ${webhookUrl} for repo ${repoUrl}`);\n const { host, owner, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError('Invalid repository owner provided in repoUrl');\n }\n\n const client = new Octokit(\n await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n }),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const insecure_ssl = insecureSsl ? '1' : '0';\n await client.rest.repos.createWebhook({\n owner,\n repo,\n config: {\n url: webhookUrl,\n content_type: contentType,\n secret: webhookSecret,\n insecure_ssl,\n },\n events,\n active,\n });\n ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);\n } catch (e) {\n assertError(e);\n ctx.logger.warn(\n `Failed: create webhook '${webhookUrl}' on repo: '${repo}', ${e.message}`,\n );\n }\n },\n });\n}\n"],"names":["emitterEventNames","createTemplateAction","examples","parseRepoUrl","InputError","Octokit","getOctokitOptions","assertError"],"mappings":";;;;;;;;;AAkCO,SAAS,0BAA0B,OAIvC,EAAA;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,oBAAsB,EAAA,yBAAA,EAC1C,GAAA,OAAA;AAEF,EAAM,MAAA,UAAA,GAAaA,2BAAkB,MAAO,CAAA,CAAA,KAAA,KAAS,CAAC,KAAM,CAAA,QAAA,CAAS,GAAG,CAAC,CAAA;AAEzE,EAAA,OAAOC,yCASJ,CAAA;AAAA,IACD,EAAI,EAAA,gBAAA;AAAA,IACJ,WAAa,EAAA,6CAAA;AAAA,cACbC,+BAAA;AAAA,IACA,cAAgB,EAAA,IAAA;AAAA,IAChB,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MAAA,YAAA,GAAe,cAAc,GAAM,GAAA,GAAA;AACzC,QAAM,MAAA,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,aAAc,CAAA;AAAA,UACpC,KAAA;AAAA,UACA,IAAA;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,GAAK,EAAA,UAAA;AAAA,YACL,YAAc,EAAA,WAAA;AAAA,YACd,MAAQ,EAAA,aAAA;AAAA,YACR;AAAA,WACF;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACD,CAAA;AACD,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA,CAAK,CAAY,SAAA,EAAA,UAAU,CAAwB,sBAAA,CAAA,CAAA;AAAA,eACvD,CAAG,EAAA;AACV,QAAAC,kBAAA,CAAY,CAAC,CAAA;AACb,QAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,UACT,2BAA2B,UAAU,CAAA,YAAA,EAAe,IAAI,CAAA,GAAA,EAAM,EAAE,OAAO,CAAA;AAAA,SACzE;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  const repoUrl = {
4
4
  title: "Repository Location",
5
- description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`,
5
+ description: "Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username",
6
6
  type: "string"
7
7
  };
8
8
  const description = {
@@ -15,7 +15,7 @@ const homepage = {
15
15
  };
16
16
  const access = {
17
17
  title: "Repository Access",
18
- description: `Sets an admin collaborator on the repository. Can either be a user reference different from 'owner' in 'repoUrl' or team reference, eg. 'org/team-name'`,
18
+ description: "Sets an admin collaborator on the repository. Can either be a user reference different from `owner` in `repoUrl` or team reference, eg. `org/team-name`",
19
19
  type: "string"
20
20
  };
21
21
  const requireCodeOwnerReviews = {
@@ -38,8 +38,9 @@ const requiredStatusCheckContexts = {
38
38
  };
39
39
  const requireBranchesToBeUpToDate = {
40
40
  title: "Require Branches To Be Up To Date?",
41
- description: `Require branches to be up to date before merging. The default value is 'true'`,
42
- type: "boolean"
41
+ description: "Require branches to be up to date before merging. The default value is `true`",
42
+ type: "boolean",
43
+ default: true
43
44
  };
44
45
  const requiredConversationResolution = {
45
46
  title: "Required Conversation Resolution",
@@ -49,7 +50,8 @@ const requiredConversationResolution = {
49
50
  const requireLastPushApproval = {
50
51
  title: "Require last push approval",
51
52
  type: "boolean",
52
- description: `Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is 'false'`
53
+ default: false,
54
+ description: "Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is `false`"
53
55
  };
54
56
  const repoVisibility = {
55
57
  title: "Repository Visibility",
@@ -59,12 +61,14 @@ const repoVisibility = {
59
61
  const deleteBranchOnMerge = {
60
62
  title: "Delete Branch On Merge",
61
63
  type: "boolean",
62
- description: `Delete the branch after merging the PR. The default value is 'false'`
64
+ default: false,
65
+ description: "Delete the branch after merging the PR. The default value is `false`"
63
66
  };
64
67
  const gitAuthorName = {
65
68
  title: "Default Author Name",
66
69
  type: "string",
67
- description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
70
+ default: "Scaffolder",
71
+ description: "Sets the default author name for the commit. The default value is `Scaffolder`"
68
72
  };
69
73
  const gitAuthorEmail = {
70
74
  title: "Default Author Email",
@@ -74,32 +78,40 @@ const gitAuthorEmail = {
74
78
  const allowMergeCommit = {
75
79
  title: "Allow Merge Commits",
76
80
  type: "boolean",
77
- description: `Allow merge commits. The default value is 'true'`
81
+ default: true,
82
+ description: "Allow merge commits. The default value is `true`"
78
83
  };
79
84
  const allowSquashMerge = {
80
85
  title: "Allow Squash Merges",
81
86
  type: "boolean",
82
- description: `Allow squash merges. The default value is 'true'`
87
+ default: true,
88
+ description: "Allow squash merges. The default value is `true`"
83
89
  };
84
90
  const squashMergeCommitTitle = {
85
91
  title: "Default squash merge commit title",
86
92
  enum: ["PR_TITLE", "COMMIT_OR_PR_TITLE"],
87
- description: `Sets the default value for a squash merge commit title. The default value is 'COMMIT_OR_PR_TITLE'`
93
+ type: "string",
94
+ default: "COMMIT_OR_PR_TITLE",
95
+ description: "Sets the default value for a squash merge commit title. The default value is `COMMIT_OR_PR_TITLE`"
88
96
  };
89
97
  const squashMergeCommitMessage = {
90
98
  title: "Default squash merge commit message",
91
99
  enum: ["PR_BODY", "COMMIT_MESSAGES", "BLANK"],
92
- description: `Sets the default value for a squash merge commit message. The default value is 'COMMIT_MESSAGES'`
100
+ type: "string",
101
+ default: "COMMIT_MESSAGES",
102
+ description: "Sets the default value for a squash merge commit message. The default value is `COMMIT_MESSAGES`"
93
103
  };
94
104
  const allowRebaseMerge = {
95
105
  title: "Allow Rebase Merges",
96
106
  type: "boolean",
97
- description: `Allow rebase merges. The default value is 'true'`
107
+ default: true,
108
+ description: "Allow rebase merges. The default value is `true`"
98
109
  };
99
110
  const allowAutoMerge = {
100
111
  title: "Allow Auto Merges",
101
112
  type: "boolean",
102
- description: `Allow individual PRs to merge automatically when all merge requirements are met. The default value is 'false'`
113
+ default: false,
114
+ description: "Allow individual PRs to merge automatically when all merge requirements are met. The default value is `false`"
103
115
  };
104
116
  const collaborators = {
105
117
  title: "Collaborators",
@@ -129,17 +141,19 @@ const collaborators = {
129
141
  const hasProjects = {
130
142
  title: "Enable projects",
131
143
  type: "boolean",
132
- description: `Enable projects for the repository. The default value is 'true' unless the organization has disabled repository projects`
144
+ description: "Enable projects for the repository. The default value is `true` unless the organization has disabled repository projects"
133
145
  };
134
146
  const hasWiki = {
135
147
  title: "Enable the wiki",
136
148
  type: "boolean",
137
- description: `Enable the wiki for the repository. The default value is 'true'`
149
+ default: true,
150
+ description: "Enable the wiki for the repository. The default value is `true`"
138
151
  };
139
152
  const hasIssues = {
140
153
  title: "Enable issues",
141
154
  type: "boolean",
142
- description: `Enable issues for the repository. The default value is 'true'`
155
+ default: true,
156
+ description: "Enable issues for the repository. The default value is `true`"
143
157
  };
144
158
  const token = {
145
159
  title: "Authentication Token",
@@ -156,17 +170,20 @@ const topics = {
156
170
  const defaultBranch = {
157
171
  title: "Default Branch",
158
172
  type: "string",
159
- description: `Sets the default branch on the repository. The default value is 'master'`
173
+ default: "master",
174
+ description: "Sets the default branch on the repository. The default value is `master`"
160
175
  };
161
176
  const protectDefaultBranch = {
162
177
  title: "Protect Default Branch",
163
178
  type: "boolean",
164
- description: `Protect the default branch after creating the repository. The default value is 'true'`
179
+ default: true,
180
+ description: "Protect the default branch after creating the repository. The default value is `true`"
165
181
  };
166
182
  const protectEnforceAdmins = {
167
183
  title: "Enforce Admins On Protected Branches",
168
184
  type: "boolean",
169
- description: `Enforce admins to adhere to default branch protection. The default value is 'true'`
185
+ default: true,
186
+ description: "Enforce admins to adhere to default branch protection. The default value is `true`"
170
187
  };
171
188
  const bypassPullRequestAllowances = {
172
189
  title: "Bypass pull request requirements",
@@ -197,7 +214,8 @@ const bypassPullRequestAllowances = {
197
214
  const gitCommitMessage = {
198
215
  title: "Git Commit Message",
199
216
  type: "string",
200
- description: `Sets the commit message on the repository. The default value is 'initial commit'`
217
+ default: "initial commit",
218
+ description: "Sets the commit message on the repository. The default value is `initial commit`"
201
219
  };
202
220
  const sourcePath = {
203
221
  title: "Source Path",
@@ -207,7 +225,7 @@ const sourcePath = {
207
225
  const requiredApprovingReviewCount = {
208
226
  title: "Required approving review count",
209
227
  type: "number",
210
- description: `Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6 or 0 to not require reviewers. Defaults to 1.`
228
+ description: "Specify the number of reviewers required to approve pull requests. Use a number between `1` and `6` or `0` to not require reviewers. Defaults to `1`."
211
229
  };
212
230
  const restrictions = {
213
231
  title: "Restrict who can push to the protected branch",
@@ -1 +1 @@
1
- {"version":3,"file":"inputProperties.cjs.js","sources":["../../src/actions/inputProperties.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\nconst 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};\nconst description = {\n title: 'Repository Description',\n type: 'string',\n};\nconst homepage = {\n title: 'Repository Homepage',\n type: 'string',\n};\nconst access = {\n title: 'Repository Access',\n description: `Sets an admin collaborator on the repository. Can either be a user reference different from 'owner' in 'repoUrl' or team reference, eg. 'org/team-name'`,\n type: 'string',\n};\nconst requireCodeOwnerReviews = {\n title: 'Require CODEOWNER Reviews?',\n description:\n 'Require an approved review in PR including files with a designated Code Owner',\n type: 'boolean',\n};\nconst dismissStaleReviews = {\n title: 'Dismiss Stale Reviews',\n description:\n 'New reviewable commits pushed to a matching branch will dismiss pull request review approvals.',\n type: 'boolean',\n};\nconst requiredStatusCheckContexts = {\n title: 'Required Status Check Contexts',\n description:\n 'The list of status checks to require in order to merge into this branch',\n type: 'array',\n items: {\n type: 'string',\n },\n};\nconst requireBranchesToBeUpToDate = {\n title: 'Require Branches To Be Up To Date?',\n description: `Require branches to be up to date before merging. The default value is 'true'`,\n type: 'boolean',\n};\nconst requiredConversationResolution = {\n title: 'Required Conversation Resolution',\n description:\n 'Requires all conversations on code to be resolved before a pull request can be merged into this branch',\n type: 'boolean',\n};\nconst requireLastPushApproval = {\n title: 'Require last push approval',\n type: 'boolean',\n description: `Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is 'false'`,\n};\nconst repoVisibility = {\n title: 'Repository Visibility',\n type: 'string',\n enum: ['private', 'public', 'internal'],\n};\nconst deleteBranchOnMerge = {\n title: 'Delete Branch On Merge',\n type: 'boolean',\n description: `Delete the branch after merging the PR. The default value is 'false'`,\n};\nconst gitAuthorName = {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n};\nconst gitAuthorEmail = {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n};\nconst allowMergeCommit = {\n title: 'Allow Merge Commits',\n type: 'boolean',\n description: `Allow merge commits. The default value is 'true'`,\n};\nconst allowSquashMerge = {\n title: 'Allow Squash Merges',\n type: 'boolean',\n description: `Allow squash merges. The default value is 'true'`,\n};\nconst squashMergeCommitTitle = {\n title: 'Default squash merge commit title',\n enum: ['PR_TITLE', 'COMMIT_OR_PR_TITLE'],\n description: `Sets the default value for a squash merge commit title. The default value is 'COMMIT_OR_PR_TITLE'`,\n};\nconst squashMergeCommitMessage = {\n title: 'Default squash merge commit message',\n enum: ['PR_BODY', 'COMMIT_MESSAGES', 'BLANK'],\n description: `Sets the default value for a squash merge commit message. The default value is 'COMMIT_MESSAGES'`,\n};\n\nconst allowRebaseMerge = {\n title: 'Allow Rebase Merges',\n type: 'boolean',\n description: `Allow rebase merges. The default value is 'true'`,\n};\nconst allowAutoMerge = {\n title: 'Allow Auto Merges',\n type: 'boolean',\n description: `Allow individual PRs to merge automatically when all merge requirements are met. The default value is 'false'`,\n};\nconst collaborators = {\n title: 'Collaborators',\n description: 'Provide additional users or teams with permissions',\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['access'],\n properties: {\n access: {\n type: 'string',\n description: 'The type of access for the user',\n },\n user: {\n type: 'string',\n description:\n 'The name of the user that will be added as a collaborator',\n },\n team: {\n type: 'string',\n description:\n 'The name of the team that will be added as a collaborator',\n },\n },\n oneOf: [{ required: ['user'] }, { required: ['team'] }],\n },\n};\nconst hasProjects = {\n title: 'Enable projects',\n type: 'boolean',\n description: `Enable projects for the repository. The default value is 'true' unless the organization has disabled repository projects`,\n};\nconst hasWiki = {\n title: 'Enable the wiki',\n type: 'boolean',\n description: `Enable the wiki for the repository. The default value is 'true'`,\n};\nconst hasIssues = {\n title: 'Enable issues',\n type: 'boolean',\n description: `Enable issues for the repository. The default value is 'true'`,\n};\nconst token = {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n};\nconst topics = {\n title: 'Topics',\n type: 'array',\n items: {\n type: 'string',\n },\n};\nconst defaultBranch = {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n};\nconst protectDefaultBranch = {\n title: 'Protect Default Branch',\n type: 'boolean',\n description: `Protect the default branch after creating the repository. The default value is 'true'`,\n};\nconst protectEnforceAdmins = {\n title: 'Enforce Admins On Protected Branches',\n type: 'boolean',\n description: `Enforce admins to adhere to default branch protection. The default value is 'true'`,\n};\n\nconst bypassPullRequestAllowances = {\n title: 'Bypass pull request requirements',\n description:\n 'Allow specific users, teams, or apps to bypass pull request requirements.',\n type: 'object',\n additionalProperties: false,\n properties: {\n apps: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n users: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n teams: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n};\n\nconst gitCommitMessage = {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n};\nconst sourcePath = {\n title: 'Source Path',\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n type: 'string',\n};\n\nconst requiredApprovingReviewCount = {\n title: 'Required approving review count',\n type: 'number',\n description: `Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6 or 0 to not require reviewers. Defaults to 1.`,\n};\n\nconst restrictions = {\n title: 'Restrict who can push to the protected branch',\n description:\n 'Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories.',\n type: 'object',\n additionalProperties: false,\n properties: {\n apps: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n users: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n teams: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n};\n\nconst requiredCommitSigning = {\n title: 'Require commit signing',\n type: 'boolean',\n description: `Require commit signing so that you must sign commits on this branch.`,\n};\n\nconst requiredLinearHistory = {\n title: 'Require linear history',\n type: 'boolean',\n description: `Prevent merge commits from being pushed to matching branches.`,\n};\n\nconst repoVariables = {\n title: 'Repository Variables',\n description: `Variables attached to the repository`,\n type: 'object',\n};\n\nconst secrets = {\n title: 'Repository Secrets',\n description: `Secrets attached to the repository`,\n type: 'object',\n};\n\nconst oidcCustomization = {\n title: 'Repository OIDC customization template',\n description: `OIDC customization template attached to the repository.`,\n type: 'object',\n additionalProperties: false,\n properties: {\n useDefault: {\n title: 'Use Default',\n type: 'boolean',\n description: `Whether to use the default OIDC template or not.`,\n },\n includeClaimKeys: {\n title: 'Include claim keys',\n type: 'array',\n items: {\n type: 'string',\n },\n description: `Array of unique strings. Each claim key can only contain alphanumeric characters and underscores.`,\n },\n },\n};\n\nconst customProperties = {\n title: 'Custom Repository Properties',\n description:\n 'Custom properties to be added to the repository (note, this only works for organization repositories)',\n type: 'object',\n};\n\nconst subscribe = {\n title: 'Subscribe to repository',\n description: `Subscribe to the repository. The default value is 'false'`,\n type: 'boolean',\n};\n\nexport { access };\nexport { allowMergeCommit };\nexport { allowRebaseMerge };\nexport { allowSquashMerge };\nexport { squashMergeCommitTitle };\nexport { squashMergeCommitMessage };\nexport { allowAutoMerge };\nexport { collaborators };\nexport { defaultBranch };\nexport { deleteBranchOnMerge };\nexport { description };\nexport { gitAuthorEmail };\nexport { gitAuthorName };\nexport { gitCommitMessage };\nexport { homepage };\nexport { protectDefaultBranch };\nexport { protectEnforceAdmins };\nexport { bypassPullRequestAllowances };\nexport { requiredApprovingReviewCount };\nexport { restrictions };\nexport { repoUrl };\nexport { repoVisibility };\nexport { requireCodeOwnerReviews };\nexport { dismissStaleReviews };\nexport { requiredStatusCheckContexts };\nexport { requireBranchesToBeUpToDate };\nexport { requiredConversationResolution };\nexport { requireLastPushApproval };\nexport { hasProjects };\nexport { hasIssues };\nexport { hasWiki };\nexport { sourcePath };\nexport { token };\nexport { topics };\nexport { requiredCommitSigning };\nexport { requiredLinearHistory };\nexport { repoVariables };\nexport { secrets };\nexport { oidcCustomization };\nexport { customProperties };\nexport { subscribe };\n"],"names":[],"mappings":";;AAgBA,MAAM,OAAU,GAAA;AAAA,EACd,KAAO,EAAA,qBAAA;AAAA,EACP,WAAa,EAAA,CAAA,gJAAA,CAAA;AAAA,EACb,IAAM,EAAA;AACR;AACA,MAAM,WAAc,GAAA;AAAA,EAClB,KAAO,EAAA,wBAAA;AAAA,EACP,IAAM,EAAA;AACR;AACA,MAAM,QAAW,GAAA;AAAA,EACf,KAAO,EAAA,qBAAA;AAAA,EACP,IAAM,EAAA;AACR;AACA,MAAM,MAAS,GAAA;AAAA,EACb,KAAO,EAAA,mBAAA;AAAA,EACP,WAAa,EAAA,CAAA,uJAAA,CAAA;AAAA,EACb,IAAM,EAAA;AACR;AACA,MAAM,uBAA0B,GAAA;AAAA,EAC9B,KAAO,EAAA,4BAAA;AAAA,EACP,WACE,EAAA,+EAAA;AAAA,EACF,IAAM,EAAA;AACR;AACA,MAAM,mBAAsB,GAAA;AAAA,EAC1B,KAAO,EAAA,uBAAA;AAAA,EACP,WACE,EAAA,gGAAA;AAAA,EACF,IAAM,EAAA;AACR;AACA,MAAM,2BAA8B,GAAA;AAAA,EAClC,KAAO,EAAA,gCAAA;AAAA,EACP,WACE,EAAA,yEAAA;AAAA,EACF,IAAM,EAAA,OAAA;AAAA,EACN,KAAO,EAAA;AAAA,IACL,IAAM,EAAA;AAAA;AAEV;AACA,MAAM,2BAA8B,GAAA;AAAA,EAClC,KAAO,EAAA,oCAAA;AAAA,EACP,WAAa,EAAA,CAAA,6EAAA,CAAA;AAAA,EACb,IAAM,EAAA;AACR;AACA,MAAM,8BAAiC,GAAA;AAAA,EACrC,KAAO,EAAA,kCAAA;AAAA,EACP,WACE,EAAA,wGAAA;AAAA,EACF,IAAM,EAAA;AACR;AACA,MAA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U,GAAA;AAAA,EACd,KAAO,EAAA,oBAAA;AAAA,EACP,WAAa,EAAA,CAAA,kCAAA,CAAA;AAAA,EACb,IAAM,EAAA;AACR;AAEA,MAAM,iBAAoB,GAAA;AAAA,EACxB,KAAO,EAAA,wCAAA;AAAA,EACP,WAAa,EAAA,CAAA,uDAAA,CAAA;AAAA,EACb,IAAM,EAAA,QAAA;AAAA,EACN,oBAAsB,EAAA,KAAA;AAAA,EACtB,UAAY,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,MACV,KAAO,EAAA,aAAA;AAAA,MACP,IAAM,EAAA,SAAA;AAAA,MACN,WAAa,EAAA,CAAA,gDAAA;AAAA,KACf;AAAA,IACA,gBAAkB,EAAA;AAAA,MAChB,KAAO,EAAA,oBAAA;AAAA,MACP,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA;AAAA,OACR;AAAA,MACA,WAAa,EAAA,CAAA,iGAAA;AAAA;AACf;AAEJ;AAEA,MAAM,gBAAmB,GAAA;AAAA,EACvB,KAAO,EAAA,8BAAA;AAAA,EACP,WACE,EAAA,uGAAA;AAAA,EACF,IAAM,EAAA;AACR;AAEA,MAAM,SAAY,GAAA;AAAA,EAChB,KAAO,EAAA,yBAAA;AAAA,EACP,WAAa,EAAA,CAAA,yDAAA,CAAA;AAAA,EACb,IAAM,EAAA;AACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"inputProperties.cjs.js","sources":["../../src/actions/inputProperties.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\nconst repoUrl = {\n title: 'Repository Location',\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 type: 'string',\n};\nconst description = {\n title: 'Repository Description',\n type: 'string',\n};\nconst homepage = {\n title: 'Repository Homepage',\n type: 'string',\n};\nconst access = {\n title: 'Repository Access',\n description:\n 'Sets an admin collaborator on the repository. Can either be a user reference different from `owner` in `repoUrl` or team reference, eg. `org/team-name`',\n type: 'string',\n};\nconst requireCodeOwnerReviews = {\n title: 'Require CODEOWNER Reviews?',\n description:\n 'Require an approved review in PR including files with a designated Code Owner',\n type: 'boolean',\n};\nconst dismissStaleReviews = {\n title: 'Dismiss Stale Reviews',\n description:\n 'New reviewable commits pushed to a matching branch will dismiss pull request review approvals.',\n type: 'boolean',\n};\nconst requiredStatusCheckContexts = {\n title: 'Required Status Check Contexts',\n description:\n 'The list of status checks to require in order to merge into this branch',\n type: 'array',\n items: {\n type: 'string',\n },\n};\nconst requireBranchesToBeUpToDate = {\n title: 'Require Branches To Be Up To Date?',\n description:\n 'Require branches to be up to date before merging. The default value is `true`',\n type: 'boolean',\n default: true,\n};\nconst requiredConversationResolution = {\n title: 'Required Conversation Resolution',\n description:\n 'Requires all conversations on code to be resolved before a pull request can be merged into this branch',\n type: 'boolean',\n};\nconst requireLastPushApproval = {\n title: 'Require last push approval',\n type: 'boolean',\n default: false,\n description:\n 'Whether the most recent push to a PR must be approved by someone other than the person who pushed it. The default value is `false`',\n};\nconst repoVisibility = {\n title: 'Repository Visibility',\n type: 'string',\n enum: ['private', 'public', 'internal'],\n};\nconst deleteBranchOnMerge = {\n title: 'Delete Branch On Merge',\n type: 'boolean',\n default: false,\n description:\n 'Delete the branch after merging the PR. The default value is `false`',\n};\nconst gitAuthorName = {\n title: 'Default Author Name',\n type: 'string',\n default: 'Scaffolder',\n description:\n 'Sets the default author name for the commit. The default value is `Scaffolder`',\n};\nconst gitAuthorEmail = {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n};\nconst allowMergeCommit = {\n title: 'Allow Merge Commits',\n type: 'boolean',\n default: true,\n description: 'Allow merge commits. The default value is `true`',\n};\nconst allowSquashMerge = {\n title: 'Allow Squash Merges',\n type: 'boolean',\n default: true,\n description: 'Allow squash merges. The default value is `true`',\n};\nconst squashMergeCommitTitle = {\n title: 'Default squash merge commit title',\n enum: ['PR_TITLE', 'COMMIT_OR_PR_TITLE'],\n type: 'string',\n default: 'COMMIT_OR_PR_TITLE',\n description:\n 'Sets the default value for a squash merge commit title. The default value is `COMMIT_OR_PR_TITLE`',\n};\nconst squashMergeCommitMessage = {\n title: 'Default squash merge commit message',\n enum: ['PR_BODY', 'COMMIT_MESSAGES', 'BLANK'],\n type: 'string',\n default: 'COMMIT_MESSAGES',\n description:\n 'Sets the default value for a squash merge commit message. The default value is `COMMIT_MESSAGES`',\n};\n\nconst allowRebaseMerge = {\n title: 'Allow Rebase Merges',\n type: 'boolean',\n default: true,\n description: 'Allow rebase merges. The default value is `true`',\n};\nconst allowAutoMerge = {\n title: 'Allow Auto Merges',\n type: 'boolean',\n default: false,\n description:\n 'Allow individual PRs to merge automatically when all merge requirements are met. The default value is `false`',\n};\nconst collaborators = {\n title: 'Collaborators',\n description: 'Provide additional users or teams with permissions',\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['access'],\n properties: {\n access: {\n type: 'string',\n description: 'The type of access for the user',\n },\n user: {\n type: 'string',\n description:\n 'The name of the user that will be added as a collaborator',\n },\n team: {\n type: 'string',\n description:\n 'The name of the team that will be added as a collaborator',\n },\n },\n oneOf: [{ required: ['user'] }, { required: ['team'] }],\n },\n};\nconst hasProjects = {\n title: 'Enable projects',\n type: 'boolean',\n description:\n 'Enable projects for the repository. The default value is `true` unless the organization has disabled repository projects',\n};\nconst hasWiki = {\n title: 'Enable the wiki',\n type: 'boolean',\n default: true,\n description:\n 'Enable the wiki for the repository. The default value is `true`',\n};\nconst hasIssues = {\n title: 'Enable issues',\n type: 'boolean',\n default: true,\n description: 'Enable issues for the repository. The default value is `true`',\n};\nconst token = {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n};\nconst topics = {\n title: 'Topics',\n type: 'array',\n items: {\n type: 'string',\n },\n};\nconst defaultBranch = {\n title: 'Default Branch',\n type: 'string',\n default: 'master',\n description:\n 'Sets the default branch on the repository. The default value is `master`',\n};\nconst protectDefaultBranch = {\n title: 'Protect Default Branch',\n type: 'boolean',\n default: true,\n description:\n 'Protect the default branch after creating the repository. The default value is `true`',\n};\nconst protectEnforceAdmins = {\n title: 'Enforce Admins On Protected Branches',\n type: 'boolean',\n default: true,\n description:\n 'Enforce admins to adhere to default branch protection. The default value is `true`',\n};\n\nconst bypassPullRequestAllowances = {\n title: 'Bypass pull request requirements',\n description:\n 'Allow specific users, teams, or apps to bypass pull request requirements.',\n type: 'object',\n additionalProperties: false,\n properties: {\n apps: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n users: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n teams: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n};\n\nconst gitCommitMessage = {\n title: 'Git Commit Message',\n type: 'string',\n default: 'initial commit',\n description:\n 'Sets the commit message on the repository. The default value is `initial commit`',\n};\nconst sourcePath = {\n title: 'Source Path',\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n type: 'string',\n};\n\nconst requiredApprovingReviewCount = {\n title: 'Required approving review count',\n type: 'number',\n description:\n 'Specify the number of reviewers required to approve pull requests. Use a number between `1` and `6` or `0` to not require reviewers. Defaults to `1`.',\n};\n\nconst restrictions = {\n title: 'Restrict who can push to the protected branch',\n description:\n 'Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories.',\n type: 'object',\n additionalProperties: false,\n properties: {\n apps: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n users: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n teams: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n};\n\nconst requiredCommitSigning = {\n title: 'Require commit signing',\n type: 'boolean',\n description: `Require commit signing so that you must sign commits on this branch.`,\n};\n\nconst requiredLinearHistory = {\n title: 'Require linear history',\n type: 'boolean',\n description: `Prevent merge commits from being pushed to matching branches.`,\n};\n\nconst repoVariables = {\n title: 'Repository Variables',\n description: `Variables attached to the repository`,\n type: 'object',\n};\n\nconst secrets = {\n title: 'Repository Secrets',\n description: `Secrets attached to the repository`,\n type: 'object',\n};\n\nconst oidcCustomization = {\n title: 'Repository OIDC customization template',\n description: `OIDC customization template attached to the repository.`,\n type: 'object',\n additionalProperties: false,\n properties: {\n useDefault: {\n title: 'Use Default',\n type: 'boolean',\n description: `Whether to use the default OIDC template or not.`,\n },\n includeClaimKeys: {\n title: 'Include claim keys',\n type: 'array',\n items: {\n type: 'string',\n },\n description: `Array of unique strings. Each claim key can only contain alphanumeric characters and underscores.`,\n },\n },\n};\n\nconst customProperties = {\n title: 'Custom Repository Properties',\n description:\n 'Custom properties to be added to the repository (note, this only works for organization repositories)',\n type: 'object',\n};\n\nconst subscribe = {\n title: 'Subscribe to repository',\n description: `Subscribe to the repository. The default value is 'false'`,\n type: 'boolean',\n};\n\nexport { access };\nexport { allowMergeCommit };\nexport { allowRebaseMerge };\nexport { allowSquashMerge };\nexport { squashMergeCommitTitle };\nexport { squashMergeCommitMessage };\nexport { allowAutoMerge };\nexport { collaborators };\nexport { defaultBranch };\nexport { deleteBranchOnMerge };\nexport { description };\nexport { gitAuthorEmail };\nexport { gitAuthorName };\nexport { gitCommitMessage };\nexport { homepage };\nexport { protectDefaultBranch };\nexport { protectEnforceAdmins };\nexport { bypassPullRequestAllowances };\nexport { requiredApprovingReviewCount };\nexport { restrictions };\nexport { repoUrl };\nexport { repoVisibility };\nexport { requireCodeOwnerReviews };\nexport { dismissStaleReviews };\nexport { requiredStatusCheckContexts };\nexport { requireBranchesToBeUpToDate };\nexport { requiredConversationResolution };\nexport { requireLastPushApproval };\nexport { hasProjects };\nexport { hasIssues };\nexport { hasWiki };\nexport { sourcePath };\nexport { token };\nexport { topics };\nexport { requiredCommitSigning };\nexport { requiredLinearHistory };\nexport { repoVariables };\nexport { secrets };\nexport { oidcCustomization };\nexport { customProperties };\nexport { subscribe };\n"],"names":[],"mappings":";;AAgBA,MAAM,OAAU,GAAA;AAAA,EACd,KAAO,EAAA,qBAAA;AAAA,EACP,WACE,EAAA,kJAAA;AAAA,EACF,IAAM,EAAA;AACR;AACA,MAAM,WAAc,GAAA;AAAA,EAClB,KAAO,EAAA,wBAAA;AAAA,EACP,IAAM,EAAA;AACR;AACA,MAAM,QAAW,GAAA;AAAA,EACf,KAAO,EAAA,qBAAA;AAAA,EACP,IAAM,EAAA;AACR;AACA,MAAM,MAAS,GAAA;AAAA,EACb,KAAO,EAAA,mBAAA;AAAA,EACP,WACE,EAAA,yJAAA;AAAA,EACF,IAAM,EAAA;AACR;AACA,MAAM,uBAA0B,GAAA;AAAA,EAC9B,KAAO,EAAA,4BAAA;AAAA,EACP,WACE,EAAA,+EAAA;AAAA,EACF,IAAM,EAAA;AACR;AACA,MAAM,mBAAsB,GAAA;AAAA,EAC1B,KAAO,EAAA,uBAAA;AAAA,EACP,WACE,EAAA,gGAAA;AAAA,EACF,IAAM,EAAA;AACR;AACA,MAAM,2BAA8B,GAAA;AAAA,EAClC,KAAO,EAAA,gCAAA;AAAA,EACP,WACE,EAAA,yEAAA;AAAA,EACF,IAAM,EAAA,OAAA;AAAA,EACN,KAAO,EAAA;AAAA,IACL,IAAM,EAAA;AAAA;AAEV;AACA,MAAM,2BAA8B,GAAA;AAAA,EAClC,KAAO,EAAA,oCAAA;AAAA,EACP,WACE,EAAA,+EAAA;AAAA,EACF,IAAM,EAAA,SAAA;AAAA,EACN,OAAS,EAAA;AACX;AACA,MAAM,8BAAiC,GAAA;AAAA,EACrC,KAAO,EAAA,kCAAA;AAAA,EACP,WACE,EAA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CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-github",
3
- "version": "0.6.0-next.2",
3
+ "version": "0.6.1-next.0",
4
4
  "description": "The github module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -51,13 +51,13 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@backstage/backend-common": "^0.25.0",
54
- "@backstage/backend-plugin-api": "1.2.0-next.2",
54
+ "@backstage/backend-plugin-api": "1.2.1-next.0",
55
55
  "@backstage/catalog-client": "1.9.1",
56
56
  "@backstage/catalog-model": "1.7.3",
57
57
  "@backstage/config": "1.3.2",
58
58
  "@backstage/errors": "1.2.7",
59
59
  "@backstage/integration": "1.16.1",
60
- "@backstage/plugin-scaffolder-node": "0.7.0-next.2",
60
+ "@backstage/plugin-scaffolder-node": "0.7.1-next.0",
61
61
  "@octokit/webhooks": "^10.9.2",
62
62
  "libsodium-wrappers": "^0.7.11",
63
63
  "octokit": "^3.0.0",
@@ -65,9 +65,9 @@
65
65
  "yaml": "^2.0.0"
66
66
  },
67
67
  "devDependencies": {
68
- "@backstage/backend-test-utils": "1.3.0-next.3",
69
- "@backstage/cli": "0.30.0-next.3",
70
- "@backstage/plugin-scaffolder-node-test-utils": "0.1.19-next.3",
68
+ "@backstage/backend-test-utils": "1.3.1-next.0",
69
+ "@backstage/cli": "0.30.0",
70
+ "@backstage/plugin-scaffolder-node-test-utils": "0.1.20-next.0",
71
71
  "@types/libsodium-wrappers": "^0.7.10",
72
72
  "fs-extra": "^11.2.0",
73
73
  "jsonschema": "^1.2.6"