Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build & Deploy (staging)

on:
workflow_dispatch:
push:
branches:
- development

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: staging
steps:
- name: Discord Webhook Action
uses: tsickert/discord-webhook@v5.3.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: "Docs repository was updated. Deploying to staging..."

- name: Checkout repository
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9.1

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build app
run: pnpm build

- name: Deploy to S3
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: 'build'

- name: Invalidate AWS CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ vars.AWS_CLOUDFRONT_DISTRIBUTION_ID }}
PATHS: /**/* /*
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Discord Webhook Action
uses: tsickert/discord-webhook@v5.3.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: "Docs Deployed to staging. Available at: https://docs-staging.anyflow.pro"
80 changes: 80 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { themes as prismThemes } from 'prism-react-renderer';
import type { Config } from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import path from 'path';
import fs from 'fs';

const config: Config = {
title: 'AnyFlow',
Expand Down Expand Up @@ -51,6 +53,84 @@ const config: Config = {
],
],

plugins: [
// Plugin copied from https://github.com/prisma/docs
async function pluginLlmsTxt(context) {
return {
name: "llms-txt-plugin",
loadContent: async () => {
const { siteDir } = context;
const contentDir = path.join(siteDir, "docs");
const allMd: string[] = [];

// recursive function to get all md files
const getMdFiles = async (dir: string) => {
const entries = await fs.promises.readdir(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
await getMdFiles(fullPath);
} else if (entry.name.endsWith(".md")) {
const content = await fs.promises.readFile(fullPath, "utf8");
allMd.push(content);
}
}
};

await getMdFiles(contentDir);
return { allMd: allMd };
},
postBuild: async ({ content, routes, outDir }) => {
const { allMd } = content as { allMd: string[] };

// Write concatenated MD content
const concatenatedPath = path.join(outDir, "llms-full.txt");
await fs.promises.writeFile(concatenatedPath, allMd.join("\n\n---\n\n"));

// we need to dig down several layers:
// find PluginRouteConfig marked by plugin.name === "docusaurus-plugin-content-docs"
const docsPluginRouteConfig = routes.filter(
(route) => route.plugin.name === "docusaurus-plugin-content-docs"
)[0];

// docsPluginRouteConfig has a routes property has a record with the path "/" that contains all docs routes.
const allDocsRouteConfig = docsPluginRouteConfig.routes?.filter(
(route) => route.path === "/"
)[0];

let llmsTxt = '';

// A little type checking first
if (!allDocsRouteConfig?.props?.version) {
llmsTxt = ''
} else {
// this route config has a `props` property that contains the current documentation.
const currentVersionDocsRoutes = (
allDocsRouteConfig.props.version as Record<string, unknown>
).docs as Record<string, Record<string, unknown>>;

// for every single docs route we now parse a path (which is the key) and a title
const docsRecords = Object.entries(currentVersionDocsRoutes).map(([path, record]) => {
return `- [${record.title}](${path}): ${record.description}`;
});

// Build up llms.txt file
llmsTxt = `# ${context.siteConfig.title}\n\n## Docs\n\n${docsRecords.join("\n")}`;
}

// Write llms.txt file
const llmsTxtPath = path.join(outDir, "llms.txt");
try {
fs.writeFileSync(llmsTxtPath, llmsTxt);
} catch (err) {
throw err;
}
},
};
},
],

themeConfig: {
// Replace with your project's social card
image: 'img/anyflow-social-card.jpg',
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
"typecheck": "tsc"
},
"dependencies": {
"@docusaurus/core": "^3.5.2",
"@docusaurus/preset-classic": "^3.5.2",
"@docusaurus/theme-mermaid": "^3.5.2",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"@docusaurus/core": "^3.7.0",
"@docusaurus/preset-classic": "^3.7.0",
"@docusaurus/theme-mermaid": "^3.7.0",
"@mdx-js/react": "^3.0.1",
"clsx": "^2.1.1",
"prism-react-renderer": "^2.3.1",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.5.2",
"@docusaurus/tsconfig": "^3.5.2",
"@docusaurus/types": "^3.4.0",
"@docusaurus/module-type-aliases": "^3.7.0",
"@docusaurus/tsconfig": "^3.7.0",
"@docusaurus/types": "^3.7.0",
"@types/node": "^22.15.3",
"typescript": "~5.2.2"
},
"browserslist": {
Expand Down
Loading