-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build workflow job with concentrated docs artefact (#1310)
Co-authored-by: monteth <[email protected]>
- Loading branch information
Showing
2 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); |