Skip to content

Commit

Permalink
Add build workflow job with concentrated docs artefact (#1310)
Browse files Browse the repository at this point in the history
Co-authored-by: monteth <[email protected]>
  • Loading branch information
Monteth and monteth authored Jun 28, 2024
1 parent e1c4707 commit 91c1e21
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
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}`);

0 comments on commit 91c1e21

Please sign in to comment.