Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebuild script #71

Merged
merged 4 commits into from
Aug 14, 2024
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
15 changes: 3 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,8 @@ jobs:
with:
go-version: "1.21"

- name: Generate CLI docs
run: go run main.go ./tmp
working-directory: defang/src/cmd/gendocs

- name: Copy CLI docs to current repository
run: cp -r ./defang/src/cmd/gendocs/tmp/* ./docs/cli

- name: Prep CLI docs
run: npm run prep-cli-docs

- name: Prep Samples
run: npm run prep-samples
- name: Pre-build
run: npm run prebuild

- name: Build website
run: npm run build
Expand All @@ -92,6 +82,7 @@ jobs:
user_email: 41898282+github-actions[bot]@users.noreply.github.com
cname: docs.defang.io


- name: Notify Slack of Action Failures
uses: ravsamhq/[email protected]
if: ${{ always() && github.ref_name == 'main' }}
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,8 @@ jobs:
with:
go-version: "1.21"

- name: Generate CLI docs
run: go run main.go ./tmp
working-directory: defang/src/cmd/gendocs

- name: Copy CLI docs to current repository
run: cp -r ./defang/src/cmd/gendocs/tmp/* ./docs/cli

- name: Prep CLI docs
run: npm run prep-cli-docs

- name: Prep Samples
run: npm run prep-samples
- name: Pre-build
run: npm run prebuild

- name: Test build website
run: npm run build
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"prebuild": "./scripts/prebuild.sh",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc",
"prep-cli-docs": "node scripts/prep-cli-docs.js",
"prep-samples": "node scripts/prep-samples.js"
"typecheck": "tsc"
},
"dependencies": {
"@docusaurus/core": "3.0.0",
Expand Down
26 changes: 26 additions & 0 deletions scripts/prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

CWD=$(pwd)
CLI_DOCS_PATH=$(readlink -f docs/cli)

# In CI (github actions), the defang and samples repositories must be cloned
jordanstephens marked this conversation as resolved.
Show resolved Hide resolved
# into the working directory of the `defang-docs` repository.
# In local development, however, the defang and samples repositories are cloned
# into the parent directory of the `defang-docs` repository.
if [ -d "../defang" ]; then
DEFANG_PATH=$(readlink -f ../defang)
else
DEFANG_PATH=$(readlink -f ./defang)
fi
if [ -d "../samples" ]; then
SAMPLES_PATH=$(readlink -f ../samples)
else
SAMPLES_PATH=$(readlink -f ./samples)
fi

cd "$DEFANG_PATH/src/cmd/gendocs" && go run main.go "$CLI_DOCS_PATH"
cd "$CWD"
node scripts/prep-cli-docs.js
node scripts/prep-samples.js "$SAMPLES_PATH/samples"
2 changes: 1 addition & 1 deletion scripts/prep-cli-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ fs.readdirSync(directoryPath).forEach(file => {

fs.writeFileSync(filePath, fileContent);
}
});
});
12 changes: 6 additions & 6 deletions scripts/prep-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs');
const path = require('path');
const YAML = require('yaml');

const samplesDir = path.join(__dirname, '..', 'samples', 'samples');
const samplesDir = process.argv[2];

// categories are directories in the current directory (i.e. we're running in samples/ and we might have a samples/ruby/ directory)
const directories = fs.readdirSync(samplesDir).filter(file => fs.statSync(path.join(samplesDir, file)).isDirectory());
Expand All @@ -20,11 +20,11 @@ directories.forEach((sample) => {
}

// The readme should contain lines that start with the following:
// Title:
// Short Description:
// Tags:
// Languages:
//
// Title:
// Short Description:
// Tags:
// Languages:
//
// We want to extract the title, short description, tags, and languages from the readme. Tags and languages are comma separated lists.
const title = readme.match(/Title: (.*)/)[1];
const shortDescription = readme.match(/Short Description: (.*)/)[1];
Expand Down
Loading