Skip to content

Commit

Permalink
Merge pull request #14 from go-vela/feat/plugins
Browse files Browse the repository at this point in the history
feat: local and remote plugins
KillEdgier authored Jan 16, 2025
2 parents f8c0da5 + a5bd661 commit 31a870f
Showing 13 changed files with 439 additions and 325 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# GitHub Enterprise PAT used to fetch from git.target.com
GHE_PAT=ghp_1234567890abcdefghij
GHE_API_URL=https://git.target.com/api/v3

# GitHub PAT used to fetch from github.com
GITHUB_PAT=ghp_1234567890abcdefghij
4 changes: 4 additions & 0 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -30,4 +30,8 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Test build website
env:
GITHUB_PAT: ${{ secrets.DOCUSAURUS_GITHUB_PAT }}
GHE_PAT: ${{ secrets.DOCUSAURUS_GHE_PAT }}
GHE_API_URL: ${{ secrets.DOCUSAURUS_GHE_API_URL }}
run: pnpm build
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

# Misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
@@ -18,3 +19,10 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*


# Vela Plugins markdown
# docs/plugins are defined in vela-plugins/
docs/usage/plugins/registry/*.md
# except for the plugins landing page
!docs/usage/plugins/registry/index.md
File renamed without changes.
161 changes: 0 additions & 161 deletions docs/usage/plugins/registry/ansible.md

This file was deleted.

142 changes: 0 additions & 142 deletions docs/usage/plugins/registry/vault.md

This file was deleted.

24 changes: 2 additions & 22 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { themes as prismThemes } from 'prism-react-renderer';
import remoteContentVelaPlugins from './remote-vela-plugins/index.js';

// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)

@@ -15,28 +16,7 @@ const config = {
baseUrl: '/docs-v2/',
plugins: [
require.resolve('docusaurus-lunr-search'),
// [
// "docusaurus-plugin-remote-content",
// {
// // options here
// name: "plugin-content-bar", // used by CLI, must be path safe
// sourceBaseUrl: "https://<INSERT GITHUB PAT>@raw.git.target.com/DavidVader/remote-docs-bar/main/", // the base url for the markdown (gets prepended to all of the documents when fetching)
// outDir: "docs/usage/plugins/registry", // the base directory to output to.
// documents: ["DOCS.md"], // the file names to download
// modifyContent: modifyContent,
// },
// ],
// [
// "docusaurus-plugin-remote-content",
// {
// // options here
// name: "plugin-content-foo", // used by CLI, must be path safe
// sourceBaseUrl: "https://<INSERT GITHUB PAT>@raw.git.target.com/DavidVader/remote-docs-foo/main/", // the base url for the markdown (gets prepended to all of the documents when fetching)
// outDir: "docs/usage/plugins/registry", // the base directory to output to.
// documents: ["DOCS.md"], // the file names to download
// modifyContent: modifyContent,
// },
// ],
...remoteContentVelaPlugins,
],

// GitHub pages deployment config.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
"clsx": "^2.0.0",
"docusaurus-lunr-search": "^3.5.0",
"docusaurus-plugin-remote-content": "^4.0.0",
"dotenv": "^16.4.7",
"lunr": "^2.3.9",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions remote-vela-plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import remoteVelaPlugins from "./plugins.js";
import { validateEnvironment, moveLocalPluginsToDocs, modifyRemoteContent } from "./utils.js";

// this file acts as the glue for taking a combination of local plugin docs and remote downloaded docs
// to produce a set of final documents that end up in docs/plugins

// the code in this file runs when docusarus builds the static site

require("dotenv").config();

validateEnvironment(remoteVelaPlugins);

const localPluginsSourceDir = "remote-vela-plugins/local";
const allPluginsDestinationDir = "docs/usage/plugins/registry";

moveLocalPluginsToDocs(localPluginsSourceDir, allPluginsDestinationDir);

function fetchRemoteContentPlugin(plugin) {
return [
"docusaurus-plugin-remote-content",
{
performCleanup: true,
name: "plugin-content-" + plugin.name,
sourceBaseUrl: plugin.internal ?
`${process.env.GHE_API_URL}/repos/${plugin.sourceRepo}/contents/` :
`https://api.github.com/repos/${plugin.sourceRepo}/contents/`,
requestConfig: {
headers: {
"Authorization": "Bearer " + (plugin.internal ?
process.env.GHE_PAT :
process.env.GITHUB_PAT),
},
params: {
ref: plugin.sourceRef,
},
},
outDir: allPluginsDestinationDir,
documents: [plugin.sourceFileName],
modifyContent: modifyRemoteContent(plugin),
},
];
}

const remoteContentVelaPlugins = remoteVelaPlugins.map(fetchRemoteContentPlugin);

export default remoteContentVelaPlugins;
Loading

0 comments on commit 31a870f

Please sign in to comment.