Enhance documentation by adding a "Star History" section in README, i… #3
This file contains hidden or 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
| # ============================================================================= | |
| # DEPLOY DOCS WORKFLOW | |
| # ============================================================================= | |
| # Purpose: Deploy Docusaurus Documentation to GitHub Pages | |
| # Triggers: Push to main branch only | |
| # Steps: Checkout → Setup Node.js → Install deps → Build docs → Deploy | |
| # Output: Live documentation at https://guptavishal-xm1.github.io/MochaJSON/ | |
| # ============================================================================= | |
| name: Deploy Documentation | |
| on: | |
| # Trigger only on push to main branch | |
| push: | |
| branches: | |
| - main | |
| # Only trigger if docs folder or workflow files change | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/deploy-docs.yml' | |
| # Allow manual workflow dispatch for testing | |
| workflow_dispatch: | |
| # Ensure only one deployment runs at a time | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| # Set permissions for GitHub Pages deployment | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| # Build the Docusaurus documentation | |
| build-docs: | |
| name: Build Documentation | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Fetch full history for better Git operations | |
| fetch-depth: 0 | |
| # Step 2: Set up Node.js environment | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| # Use Node.js 20 LTS for stability | |
| node-version: '20' | |
| # Cache npm dependencies for faster builds | |
| cache: 'npm' | |
| cache-dependency-path: 'docs/package.json' | |
| # Step 3: Cache npm dependencies | |
| - name: Cache npm Dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| # Cache node_modules in docs folder | |
| path: docs/node_modules | |
| # Cache key includes OS, Node version, and package.json hash | |
| key: ${{ runner.os }}-node-${{ hashFiles('docs/package.json') }} | |
| # Restore from cache if no exact match | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| # Step 4: Install npm dependencies | |
| - name: Install Dependencies | |
| run: | | |
| cd docs | |
| npm install --prefer-offline --no-audit | |
| shell: bash | |
| # Step 5: Build Docusaurus documentation | |
| - name: Build Documentation | |
| run: | | |
| cd docs | |
| npm run build | |
| shell: bash | |
| env: | |
| # Set NODE_ENV for production build | |
| NODE_ENV: production | |
| # Step 6: Upload build artifacts | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docusaurus-build | |
| path: docs/build/ | |
| retention-days: 1 | |
| # Step 7: Generate build summary | |
| - name: Build Summary | |
| if: always() | |
| run: | | |
| echo "## Documentation Build Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Node.js Version**: 20" >> $GITHUB_STEP_SUMMARY | |
| echo "- **OS**: ${{ runner.os }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Build Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Build Time**: $(date)" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Target URL**: https://guptavishal-xm1.github.io/MochaJSON/" >> $GITHUB_STEP_SUMMARY | |
| # Deploy to GitHub Pages | |
| deploy-docs: | |
| name: Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| needs: build-docs | |
| # Set environment for GitHub Pages | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deploy.outputs.page_url }} | |
| steps: | |
| # Step 1: Download build artifacts | |
| - name: Download Build Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docusaurus-build | |
| path: docs/build/ | |
| # Step 2: Setup Git for deployment | |
| - name: Setup Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Step 3: Deploy to GitHub Pages | |
| - name: Deploy to GitHub Pages | |
| id: deploy | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| # Use GitHub token for authentication | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| # Deploy from docs/build directory | |
| publish_dir: docs/build/ | |
| # Disable Jekyll processing | |
| disable_nojekyll: false | |
| # Allow empty commits | |
| allow_empty_commit: true | |
| # Step 3: Deployment summary | |
| - name: Deployment Summary | |
| if: always() | |
| run: | | |
| echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Deployment Time**: $(date)" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Live URL**: https://guptavishal-xm1.github.io/MochaJSON/" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY |