|
| 1 | +name: SATP Hermes Gateway Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + deploy_docs: |
| 7 | + description: 'Deploy documentation to GitHub Pages' |
| 8 | + required: false |
| 9 | + default: true |
| 10 | + type: boolean |
| 11 | + docs_branch: |
| 12 | + description: 'Branch to build docs from' |
| 13 | + required: false |
| 14 | + default: 'main' |
| 15 | + type: string |
| 16 | + workflow_dispatch: |
| 17 | + inputs: |
| 18 | + deploy_docs: |
| 19 | + description: 'Deploy documentation to GitHub Pages' |
| 20 | + required: false |
| 21 | + default: true |
| 22 | + type: boolean |
| 23 | + docs_branch: |
| 24 | + description: 'Branch to build docs from' |
| 25 | + required: false |
| 26 | + default: 'main' |
| 27 | + type: string |
| 28 | + |
| 29 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 30 | +permissions: |
| 31 | + contents: read |
| 32 | + pages: write |
| 33 | + id-token: write |
| 34 | + |
| 35 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 36 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 37 | +concurrency: |
| 38 | + group: "pages" |
| 39 | + cancel-in-progress: false |
| 40 | + |
| 41 | +jobs: |
| 42 | + # ============================================================================= |
| 43 | + # BUILD DOCUMENTATION |
| 44 | + # ============================================================================= |
| 45 | + # This job builds the TypeDoc documentation for the SATP Hermes Gateway |
| 46 | + |
| 47 | + build-docs: |
| 48 | + runs-on: ubuntu-latest-16-cores |
| 49 | + steps: |
| 50 | + - name: Checkout code |
| 51 | + |
| 52 | + with: |
| 53 | + ref: ${{ inputs.docs_branch || github.ref }} |
| 54 | + fetch-depth: 0 |
| 55 | + |
| 56 | + - name: Setup Node.js |
| 57 | + uses: actions/setup-node@v4 |
| 58 | + with: |
| 59 | + node-version: '18' |
| 60 | + cache: 'yarn' |
| 61 | + |
| 62 | + - name: Install system dependencies for Puppeteer |
| 63 | + run: | |
| 64 | + sudo apt-get update |
| 65 | + sudo apt-get install -y \ |
| 66 | + libnss3 \ |
| 67 | + libatk-bridge2.0-0 \ |
| 68 | + libdrm2 \ |
| 69 | + libxkbcommon0 \ |
| 70 | + libxcomposite1 \ |
| 71 | + libxdamage1 \ |
| 72 | + libxfixes3 \ |
| 73 | + libxrandr2 \ |
| 74 | + libgbm1 \ |
| 75 | + libasound2 |
| 76 | +
|
| 77 | + - name: Install dependencies |
| 78 | + working-directory: ./packages/cactus-plugin-satp-hermes |
| 79 | + run: | |
| 80 | + yarn install --frozen-lockfile |
| 81 | +
|
| 82 | + - name: Generate TypeDoc documentation |
| 83 | + working-directory: ./packages/cactus-plugin-satp-hermes |
| 84 | + run: | |
| 85 | + echo "Building TypeScript project..." |
| 86 | + yarn tsc |
| 87 | + |
| 88 | + echo "Generating Mermaid diagrams and TypeDoc documentation..." |
| 89 | + yarn docs:generate |
| 90 | + |
| 91 | + echo "Validating documentation..." |
| 92 | + yarn docs:validate || true |
| 93 | +
|
| 94 | + - name: Verify documentation build |
| 95 | + working-directory: ./packages/cactus-plugin-satp-hermes |
| 96 | + run: | |
| 97 | + if [ ! -d "./public/typedoc" ]; then |
| 98 | + echo "Error: Documentation directory not found!" |
| 99 | + exit 1 |
| 100 | + fi |
| 101 | + |
| 102 | + if [ ! -f "./public/typedoc/index.html" ]; then |
| 103 | + echo "Error: Documentation index.html not found!" |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | + |
| 107 | + # Verify diagrams were generated |
| 108 | + if [ ! -d "./docs/assets/diagrams" ]; then |
| 109 | + echo "Error: Diagrams source directory not found!" |
| 110 | + exit 1 |
| 111 | + fi |
| 112 | + |
| 113 | + if [ ! -d "./public/typedoc/assets/diagrams" ]; then |
| 114 | + echo "Error: Diagrams not copied to documentation output!" |
| 115 | + exit 1 |
| 116 | + fi |
| 117 | + |
| 118 | + echo "✅ Documentation built successfully!" |
| 119 | + echo "" |
| 120 | + echo "📊 Generated diagrams:" |
| 121 | + ls -lh ./docs/assets/diagrams/ |
| 122 | + echo "" |
| 123 | + echo "📚 Documentation structure:" |
| 124 | + ls -la ./public/typedoc/ | head -20 |
| 125 | +
|
| 126 | + - name: Prepare documentation structure for GitHub Pages |
| 127 | + run: | |
| 128 | + mkdir -p ./gh-pages/cacti/satp |
| 129 | + cp -r ./packages/cactus-plugin-satp-hermes/public/typedoc/* ./gh-pages/cacti/satp/ |
| 130 | + |
| 131 | + # Create a root index.html that redirects to /cacti/satp |
| 132 | + cat > ./gh-pages/index.html << 'EOF' |
| 133 | + <!DOCTYPE html> |
| 134 | + <html> |
| 135 | + <head> |
| 136 | + <meta charset="utf-8"> |
| 137 | + <title>Redirecting to SATP Documentation</title> |
| 138 | + <meta http-equiv="refresh" content="0; url=/cacti/satp/"> |
| 139 | + <link rel="canonical" href="/cacti/satp/"> |
| 140 | + </head> |
| 141 | + <body> |
| 142 | + <p>Redirecting to <a href="/cacti/satp/">SATP Hermes Gateway Documentation</a>...</p> |
| 143 | + </body> |
| 144 | + </html> |
| 145 | + EOF |
| 146 | + |
| 147 | + echo "GitHub Pages structure prepared:" |
| 148 | + find ./gh-pages -type f | head -20 |
| 149 | +
|
| 150 | + - name: Create documentation metadata |
| 151 | + run: | |
| 152 | + VERSION=$(node -p "require('./packages/cactus-plugin-satp-hermes/package.json').version") |
| 153 | + SATP_VERSION=$(node -p "require('./packages/cactus-plugin-satp-hermes/package.json').customMetadata['satp-package-version']") |
| 154 | + |
| 155 | + cat > ./gh-pages/cacti/satp/metadata.json << EOF |
| 156 | + { |
| 157 | + "version": "$VERSION", |
| 158 | + "satp_version": "$SATP_VERSION", |
| 159 | + "build_date": "$(date -u '+%Y-%m-%d %H:%M:%S UTC')", |
| 160 | + "commit": "${{ github.sha }}", |
| 161 | + "branch": "${{ inputs.docs_branch || github.ref }}", |
| 162 | + "workflow_run": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 163 | + } |
| 164 | + EOF |
| 165 | + |
| 166 | + echo "Documentation metadata created:" |
| 167 | + cat ./gh-pages/cacti/satp/metadata.json |
| 168 | +
|
| 169 | + - name: Setup Pages |
| 170 | + if: inputs.deploy_docs == true |
| 171 | + uses: actions/configure-pages@v5 |
| 172 | + |
| 173 | + - name: Upload documentation artifact |
| 174 | + if: inputs.deploy_docs == true |
| 175 | + uses: actions/upload-pages-artifact@v3 |
| 176 | + with: |
| 177 | + path: './gh-pages' |
| 178 | + |
| 179 | + # ============================================================================= |
| 180 | + # DEPLOY TO GITHUB PAGES |
| 181 | + # ============================================================================= |
| 182 | + # This job deploys the built documentation to GitHub Pages |
| 183 | + |
| 184 | + deploy-docs: |
| 185 | + if: inputs.deploy_docs == true |
| 186 | + environment: |
| 187 | + name: github-pages |
| 188 | + url: ${{ steps.deployment.outputs.page_url }} |
| 189 | + runs-on: ubuntu-latest |
| 190 | + needs: build-docs |
| 191 | + steps: |
| 192 | + - name: Deploy to GitHub Pages |
| 193 | + id: deployment |
| 194 | + uses: actions/deploy-pages@v4 |
| 195 | + |
| 196 | + - name: Post deployment summary |
| 197 | + run: | |
| 198 | + echo "## 📚 Documentation Deployment Successful" >> $GITHUB_STEP_SUMMARY |
| 199 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 200 | + echo "**Documentation URL:** ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY |
| 201 | + echo "**Branch:** ${{ inputs.docs_branch || github.ref }}" >> $GITHUB_STEP_SUMMARY |
| 202 | + echo "**Deployed:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY |
0 commit comments