diff --git a/demo-template/template/template.yaml b/demo-template/template/template.yaml index 5d8ea3183..b42943d11 100644 --- a/demo-template/template/template.yaml +++ b/demo-template/template/template.yaml @@ -133,7 +133,7 @@ spec: description: Repository Created by Demo Template - id: enable-pages name: Enable Pages - action: github:pages + action: github:pages:enable input: repoUrl: ${{ parameters.repoUrl }} buildType: 'workflow' diff --git a/packages/backend/package.json b/packages/backend/package.json index 8868add1f..bc86f6845 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -43,7 +43,6 @@ "@frontside/backstage-plugin-graphql-backend": "^0.1.2", "@frontside/backstage-plugin-graphql-backend-module-catalog": "^0.3.0", "@internal/plugin-catalog-backend-module-backstage": "workspace:^", - "@internal/plugin-scaffolder-backend-module-github-pages": "workspace:^", "app": "^0.0.0", "better-sqlite3": "^11.0.0" }, diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 6c44b5daa..49d03f21d 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -24,7 +24,6 @@ backend.add(import('@backstage/plugin-kubernetes-backend/alpha')); backend.add(import('@backstage/plugin-proxy-backend/alpha')); backend.add(import('@backstage/plugin-scaffolder-backend/alpha')); backend.add(import('@backstage/plugin-scaffolder-backend-module-github')); -backend.add(import('@internal/plugin-scaffolder-backend-module-github-pages')); backend.add(import('@backstage/plugin-search-backend/alpha')); backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); backend.add(import('@backstage/plugin-search-backend-module-explore/alpha')); diff --git a/plugins/scaffolder-backend-module-github-pages/.eslintrc.js b/plugins/scaffolder-backend-module-github-pages/.eslintrc.js deleted file mode 100644 index e2a53a6ad..000000000 --- a/plugins/scaffolder-backend-module-github-pages/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); diff --git a/plugins/scaffolder-backend-module-github-pages/README.md b/plugins/scaffolder-backend-module-github-pages/README.md deleted file mode 100644 index 4c2beeb18..000000000 --- a/plugins/scaffolder-backend-module-github-pages/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# @internal/backstage-plugin-scaffolder-backend-module-github-pages - -The github-pages module for [@backstage/plugin-scaffolder-backend](https://www.npmjs.com/package/@backstage/plugin-scaffolder-backend). - -_This plugin was created through the Backstage CLI_ diff --git a/plugins/scaffolder-backend-module-github-pages/package.json b/plugins/scaffolder-backend-module-github-pages/package.json deleted file mode 100644 index 2a4b4c3de..000000000 --- a/plugins/scaffolder-backend-module-github-pages/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "@internal/plugin-scaffolder-backend-module-github-pages", - "description": "The github-pages module for @backstage/plugin-scaffolder-backend", - "version": "0.1.0", - "main": "src/index.ts", - "types": "src/index.ts", - "license": "Apache-2.0", - "private": true, - "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" - }, - "backstage": { - "role": "backend-plugin-module" - }, - "scripts": { - "start": "backstage-cli package start", - "build": "backstage-cli package build", - "lint": "backstage-cli package lint", - "test": "backstage-cli package test", - "clean": "backstage-cli package clean", - "prepack": "backstage-cli package prepack", - "postpack": "backstage-cli package postpack" - }, - "dependencies": { - "@backstage/backend-plugin-api": "^1.0.2-next.0", - "@backstage/errors": "^1.2.4", - "@backstage/integration": "^1.15.1", - "@backstage/plugin-scaffolder-backend-module-github": "^0.5.2-next.0", - "@backstage/plugin-scaffolder-node": "^0.5.1-next.0", - "octokit": "^3.1.2", - "yaml": "^2.0.0" - }, - "devDependencies": { - "@backstage/cli": "^0.29.0-next.0" - }, - "files": [ - "dist" - ] -} diff --git a/plugins/scaffolder-backend-module-github-pages/src/actions/index.ts b/plugins/scaffolder-backend-module-github-pages/src/actions/index.ts deleted file mode 100644 index 23c7929ac..000000000 --- a/plugins/scaffolder-backend-module-github-pages/src/actions/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './pages'; diff --git a/plugins/scaffolder-backend-module-github-pages/src/actions/pages/createGithubPagesAction.examples.ts b/plugins/scaffolder-backend-module-github-pages/src/actions/pages/createGithubPagesAction.examples.ts deleted file mode 100644 index 72c2ac16a..000000000 --- a/plugins/scaffolder-backend-module-github-pages/src/actions/pages/createGithubPagesAction.examples.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { TemplateExample } from '@backstage/plugin-scaffolder-node'; -import yaml from 'yaml'; - -export const examples: TemplateExample[] = [ - { - description: - 'Enables GitHub Pages for a repository.', - example: yaml.stringify({ - steps: [ - { - action: 'github:pages', - id: 'github-pages', - name: 'Enable GitHub Pages', - input: { - repoUrl: 'github.com?repo=repository&owner=owner', - buildType: 'workflow', - sourceBranch: 'main', - sourcePath: '/', - token: 'gph_YourGitHubToken', - }, - }, - ], - }), - }, -]; diff --git a/plugins/scaffolder-backend-module-github-pages/src/actions/pages/createGithubPagesAction.ts b/plugins/scaffolder-backend-module-github-pages/src/actions/pages/createGithubPagesAction.ts deleted file mode 100644 index 5fda21e10..000000000 --- a/plugins/scaffolder-backend-module-github-pages/src/actions/pages/createGithubPagesAction.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { InputError } from '@backstage/errors'; -import { - GithubCredentialsProvider, - ScmIntegrationRegistry, -} from '@backstage/integration'; -import { Octokit } from 'octokit'; -import { - createTemplateAction, - parseRepoUrl, -} from '@backstage/plugin-scaffolder-node'; -import { examples } from './createGithubPagesAction.examples'; -import { getOctokitOptions } from '@backstage/plugin-scaffolder-backend-module-github'; - -/** - * Creates a new action that enables GitHub Pages for a repository. - * - * @public - */ -export function createGithubPagesAction(options: { - integrations: ScmIntegrationRegistry; - githubCredentialsProvider?: GithubCredentialsProvider; -}) { - const { integrations, githubCredentialsProvider } = options; - - return createTemplateAction<{ - repoUrl: string; - buildType?: 'legacy' | 'workflow'; - sourceBranch?: string; - sourcePath?: '/' | '/docs'; - token?: string; - }>({ - id: 'github:pages', - examples, - description: 'Enables GitHub Pages for a repository.', - schema: { - input: { - type: 'object', - required: ['repoUrl'], - properties: { - repoUrl: { - title: 'Repository Location', - description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the new repository name and 'owner' is an organization or username`, - type: 'string', - }, - buildType: { - title: 'Build Type', - type: 'string', - description: 'The GitHub Pages build type - "legacy" or "workflow"', - }, - sourceBranch: { - title: 'Source Branch', - type: 'string', - description: 'The the GitHub Pages source branch', - }, - sourcePath: { - title: 'Source Path', - type: 'string', - description: 'The the GitHub Pages source path - "/" or "/docs"', - }, - token: { - title: 'Authorization Token', - type: 'string', - description: 'The token to use for authorization to GitHub', - }, - }, - }, - }, - async handler(ctx) { - const { - repoUrl, - buildType = 'workflow', - sourceBranch = 'main', - sourcePath = '/', - token: providedToken, - } = ctx.input; - - const octokitOptions = await getOctokitOptions({ - integrations, - credentialsProvider: githubCredentialsProvider, - token: providedToken, - repoUrl: repoUrl, - }); - const client = new Octokit(octokitOptions); - - const { owner, repo } = parseRepoUrl(repoUrl, integrations); - - if (!owner) { - throw new InputError('Invalid repository owner provided in repoUrl'); - } - - ctx.logger.info( - `Attempting to enable GitHub Pages for ${owner}/${repo} with "${buildType}" build type, on source branch "${sourceBranch}" and source path "${sourcePath}"`, - ); - - await client.request('POST /repos/{owner}/{repo}/pages', { - owner: owner, - repo: repo, - build_type: buildType, - source: { - branch: sourceBranch, - path: sourcePath, - }, - headers: { - 'X-GitHub-Api-Version': '2022-11-28', - }, - }); - - ctx.logger.info('Completed enabling GitHub Pages'); - }, - }); -} diff --git a/plugins/scaffolder-backend-module-github-pages/src/actions/pages/index.ts b/plugins/scaffolder-backend-module-github-pages/src/actions/pages/index.ts deleted file mode 100644 index ea6359b13..000000000 --- a/plugins/scaffolder-backend-module-github-pages/src/actions/pages/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { createGithubPagesAction } from './createGithubPagesAction'; diff --git a/plugins/scaffolder-backend-module-github-pages/src/index.ts b/plugins/scaffolder-backend-module-github-pages/src/index.ts deleted file mode 100644 index b7ba8f432..000000000 --- a/plugins/scaffolder-backend-module-github-pages/src/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/***/ -/** - * The github-pages module for @backstage/plugin-scaffolder-backend. - * - * @packageDocumentation - */ - -export * from './actions'; -export { githubPagesModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-github-pages/src/module.ts b/plugins/scaffolder-backend-module-github-pages/src/module.ts deleted file mode 100644 index 49531244e..000000000 --- a/plugins/scaffolder-backend-module-github-pages/src/module.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { - coreServices, - createBackendModule, -} from '@backstage/backend-plugin-api'; -import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; -import { createGithubPagesAction } from './actions'; -import { - DefaultGithubCredentialsProvider, - ScmIntegrations, -} from '@backstage/integration'; - -/** - * @public - * The GitHub Module for the Scaffolder Backend - */ -export const githubPagesModule = createBackendModule({ - pluginId: 'scaffolder', - moduleId: 'github-pages', - register({ registerInit }) { - registerInit({ - deps: { - scaffolder: scaffolderActionsExtensionPoint, - config: coreServices.rootConfig, - }, - async init({ scaffolder, config }) { - const integrations = ScmIntegrations.fromConfig(config); - const githubCredentialsProvider = - DefaultGithubCredentialsProvider.fromIntegrations(integrations); - - scaffolder.addActions( - createGithubPagesAction({ - integrations, - githubCredentialsProvider, - }), - ); - }, - }); - }, -}); diff --git a/yarn.lock b/yarn.lock index 32b3c3ee4..835d83c76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6169,7 +6169,7 @@ __metadata: languageName: node linkType: hard -"@backstage/plugin-scaffolder-node@npm:0.5.1-next.0, @backstage/plugin-scaffolder-node@npm:^0.5.1-next.0": +"@backstage/plugin-scaffolder-node@npm:0.5.1-next.0": version: 0.5.1-next.0 resolution: "@backstage/plugin-scaffolder-node@npm:0.5.1-next.0" dependencies: @@ -8592,21 +8592,6 @@ __metadata: languageName: unknown linkType: soft -"@internal/plugin-scaffolder-backend-module-github-pages@workspace:^, @internal/plugin-scaffolder-backend-module-github-pages@workspace:plugins/scaffolder-backend-module-github-pages": - version: 0.0.0-use.local - resolution: "@internal/plugin-scaffolder-backend-module-github-pages@workspace:plugins/scaffolder-backend-module-github-pages" - dependencies: - "@backstage/backend-plugin-api": "npm:^1.0.2-next.0" - "@backstage/cli": "npm:^0.29.0-next.0" - "@backstage/errors": "npm:^1.2.4" - "@backstage/integration": "npm:^1.15.1" - "@backstage/plugin-scaffolder-backend-module-github": "npm:^0.5.2-next.0" - "@backstage/plugin-scaffolder-node": "npm:^0.5.1-next.0" - octokit: "npm:^3.1.2" - yaml: "npm:^2.0.0" - languageName: unknown - linkType: soft - "@ioredis/commands@npm:^1.1.1": version: 1.2.0 resolution: "@ioredis/commands@npm:1.2.0" @@ -16282,7 +16267,6 @@ __metadata: "@frontside/backstage-plugin-graphql-backend": "npm:^0.1.2" "@frontside/backstage-plugin-graphql-backend-module-catalog": "npm:^0.3.0" "@internal/plugin-catalog-backend-module-backstage": "workspace:^" - "@internal/plugin-scaffolder-backend-module-github-pages": "workspace:^" app: "npm:^0.0.0" better-sqlite3: "npm:^11.0.0" languageName: unknown @@ -27772,7 +27756,7 @@ __metadata: languageName: node linkType: hard -"octokit@npm:^3.0.0, octokit@npm:^3.1.2": +"octokit@npm:^3.0.0": version: 3.2.1 resolution: "octokit@npm:3.2.1" dependencies: