|
| 1 | +name: Generate Documentation PDFs |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + tag: |
| 9 | + description: 'Tag name for the release (e.g., v1.2.3)' |
| 10 | + required: true |
| 11 | + release_name: |
| 12 | + description: 'Release title' |
| 13 | + required: false |
| 14 | + body: |
| 15 | + description: 'Release notes/body' |
| 16 | + required: false |
| 17 | + prerelease: |
| 18 | + description: 'Mark as prerelease' |
| 19 | + type: boolean |
| 20 | + required: false |
| 21 | + default: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + generate-pdfs: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: '19' |
| 34 | + cache: 'npm' |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: npm ci |
| 38 | + |
| 39 | + - name: Install Chrome for Puppeteer |
| 40 | + run: | |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install -y chromium-browser xvfb |
| 43 | + |
| 44 | + - name: Configure Chrome for headless mode |
| 45 | + run: | |
| 46 | + echo "PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser" >> $GITHUB_ENV |
| 47 | + echo "DISPLAY=:99" >> $GITHUB_ENV |
| 48 | +
|
| 49 | + - name: Start virtual display |
| 50 | + run: | |
| 51 | + Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & |
| 52 | +
|
| 53 | + - name: Enable PDF generation in config |
| 54 | + run: | |
| 55 | + sed -i 's/autoBuildPdfs: false/autoBuildPdfs: true/' docusaurus.config.js |
| 56 | +
|
| 57 | + - name: Build documentation with PDFs |
| 58 | + run: npm run build |
| 59 | + |
| 60 | + - name: Create PDF artifacts directory structure |
| 61 | + run: | |
| 62 | + mkdir -p pdf-artifacts/CoreBox |
| 63 | + mkdir -p pdf-artifacts/ElectronicsBox |
| 64 | + mkdir -p pdf-artifacts/InfinityBox |
| 65 | + mkdir -p pdf-artifacts/DiscoveryFluorescence |
| 66 | + mkdir -p pdf-artifacts/LightsheetBox |
| 67 | + mkdir -p pdf-artifacts/QBox |
| 68 | + mkdir -p pdf-artifacts/SeeedMicroscope |
| 69 | +
|
| 70 | + - name: Copy generated PDFs |
| 71 | + run: | |
| 72 | + if [ -d "build/pdfs" ]; then |
| 73 | + cp -r build/pdfs/* pdf-artifacts/ 2>/dev/null || true |
| 74 | + |
| 75 | + find build/pdfs -name "*CoreBox*EN*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true |
| 76 | + find build/pdfs -name "*CoreBox*DE*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true |
| 77 | + find build/pdfs -name "*CoreBox*FR*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true |
| 78 | + find build/pdfs -name "*CoreBox*ES*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true |
| 79 | + find build/pdfs -name "*CoreBox*AR*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true |
| 80 | + find build/pdfs -name "*core*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true |
| 81 | + |
| 82 | + find build/pdfs -name "*Electronics*" -exec cp {} pdf-artifacts/ElectronicsBox/ \; 2>/dev/null || true |
| 83 | + find build/pdfs -name "*electronics*" -exec cp {} pdf-artifacts/ElectronicsBox/ \; 2>/dev/null || true |
| 84 | + find build/pdfs -name "*Infinity*" -exec cp {} pdf-artifacts/InfinityBox/ \; 2>/dev/null || true |
| 85 | + find build/pdfs -name "*infinity*" -exec cp {} pdf-artifacts/InfinityBox/ \; 2>/dev/null || true |
| 86 | + find build/pdfs -name "*Fluorescence*" -exec cp {} pdf-artifacts/DiscoveryFluorescence/ \; 2>/dev/null || true |
| 87 | + find build/pdfs -name "*fluorescence*" -exec cp {} pdf-artifacts/DiscoveryFluorescence/ \; 2>/dev/null || true |
| 88 | + find build/pdfs -name "*Lightsheet*" -exec cp {} pdf-artifacts/LightsheetBox/ \; 2>/dev/null || true |
| 89 | + find build/pdfs -name "*lightsheet*" -exec cp {} pdf-artifacts/LightsheetBox/ \; 2>/dev/null || true |
| 90 | + find build/pdfs -name "*QBox*" -exec cp {} pdf-artifacts/QBox/ \; 2>/dev/null || true |
| 91 | + find build/pdfs -name "*qbox*" -exec cp {} pdf-artifacts/QBox/ \; 2>/dev/null || true |
| 92 | + find build/pdfs -name "*Seeed*" -exec cp {} pdf-artifacts/SeeedMicroscope/ \; 2>/dev/null || true |
| 93 | + find build/pdfs -name "*seeed*" -exec cp {} pdf-artifacts/SeeedMicroscope/ \; 2>/dev/null || true |
| 94 | + |
| 95 | + echo "Generated PDFs:" |
| 96 | + find pdf-artifacts -name "*.pdf" -type f | sort |
| 97 | + PDF_COUNT=$(find pdf-artifacts -name "*.pdf" -type f | wc -l) |
| 98 | + echo "Total PDFs generated: $PDF_COUNT" |
| 99 | + else |
| 100 | + echo "No PDFs directory found in build output" |
| 101 | + echo "Checking build structure:" |
| 102 | + ls -la build/ 2>/dev/null || echo "No build directory found" |
| 103 | + fi |
| 104 | +
|
| 105 | + - name: Upload PDFs as artifacts |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: documentation-pdfs-${{ github.run_number }} |
| 109 | + path: pdf-artifacts/ |
| 110 | + if-no-files-found: warn |
1 | 111 | - name: Prepare release variables |
2 | 112 | id: relvars |
3 | 113 | run: | |
|
0 commit comments