Deploy Website + Docs to GitHub Pages #403
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
| name: Deploy Website + Docs to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'apps/website/**' | |
| - 'docs/**' | |
| - '.github/workflows/deploy-docs.yml' | |
| workflow_dispatch: | |
| repository_dispatch: | |
| types: [pages-health-failure] | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| # Build Website (Vite React SPA) | |
| - name: Install apps/website dependencies | |
| run: cd apps/website && npm install | |
| - name: Build apps/website | |
| run: cd apps/website && npm run build:ci | |
| # Build Docsite (Docusaurus) | |
| - name: Install docs dependencies | |
| working-directory: docs | |
| run: npm install | |
| - name: Build docs | |
| working-directory: docs | |
| run: npm run build | |
| # Combine builds | |
| - name: Combine apps/website + docs | |
| run: | | |
| mkdir -p combined | |
| cp -r apps/website/dist/* combined/ | |
| # Copy CNAME from public (if exists) | |
| cp apps/website/public/CNAME combined/ 2>/dev/null || true | |
| mkdir -p combined/docs | |
| cp -r docs/build/* combined/docs/ | |
| touch combined/.nojekyll | |
| # Deploy to gh-pages branch directly | |
| - name: Deploy to gh-pages | |
| run: | | |
| cd combined | |
| git init | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add . | |
| git commit -m 'Deploy: ${{ github.event.head_commit.message }}' | |
| git push --force https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/gHashTag/trinity.git HEAD:gh-pages |