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

Add build workflow job with concentrated docs artefact #1310

Merged
merged 7 commits into from
Jun 28, 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
23 changes: 21 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,22 @@ jobs:
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Docs:
runs-on: ubuntu-latest
needs: CI
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/[email protected]
- name: Use Node.js 20
uses: actions/[email protected]
with:
cache: npm
node-version: 20
- name: Install
run: npm ci --no-audit
- name: Build docs
run: npm --prefix website run build
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.node-version == '20.x'
- name: Deploy docs
uses: peaceiris/[email protected]
with:
Expand All @@ -46,4 +59,10 @@ jobs:
force_orphan: true
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./website/build
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.node-version == '20.x'
- name: Create a concentrated doc file
run: node ./scripts/concatenateDocs.js . uniformsConcentratedDocs.md
- name: Upload the concentrated doc file as an artifact
uses: actions/upload-artifact@v3
with:
name: uniformsConcentratedDocs-${{ github.sha }}-${{ github.run_id }}-$(date +'%Y-%m-%d').md
path: uniformsConcentratedDocs.md
43 changes: 43 additions & 0 deletions scripts/concatenateDocs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* eslint no-console: "off" */

const fs = require('fs');
const path = require('path');

// Check if the correct number of arguments are passed
if (process.argv.length !== 4) {
console.log(
`Usage: node ${path.basename(__filename)} <root_directory> <output_file>`,
);
process.exit(1);
}

const rootDirectory = process.argv[2];
const outputFile = process.argv[3];

// Create or clear the output file
fs.writeFileSync(outputFile, '');

console.log(
`Starting concatenation of md files from '${rootDirectory}' directory.`,
);

// Find all .md files and concatenate their contents
function processDirectory(directory) {
fs.readdirSync(directory, { withFileTypes: true }).forEach(dirent => {
const fullPath = path.join(directory, dirent.name);
if (dirent.isDirectory() && !['node_modules'].includes(dirent.name)) {
processDirectory(fullPath);
} else if (
dirent.isFile() &&
['.md', '.mdx'].includes(path.extname(dirent.name))
) {
console.log(`Adding file: ${fullPath}`);
const data = fs.readFileSync(fullPath, 'utf8');
fs.appendFileSync(outputFile, `File: ${fullPath}\n\n${data}\n`);
}
});
}

processDirectory(rootDirectory);

console.log(`Concatenation complete. Output is in ${outputFile}`);
Loading