|
| 1 | +name: Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'docs/**' |
| 8 | + - 'packages/evolution/src/**' |
| 9 | + - 'packages/evolution/docs/**' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + pages: write |
| 16 | + id-token: write |
| 17 | + |
| 18 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 19 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 20 | +concurrency: |
| 21 | + group: "pages" |
| 22 | + cancel-in-progress: false |
| 23 | + |
| 24 | +jobs: |
| 25 | + # Build job |
| 26 | + build: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + outputs: |
| 29 | + should_build: ${{ steps.changes.outputs.should_build }} |
| 30 | + steps: |
| 31 | + - name: ⬇️ Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + fetch-depth: 0 # Need full history for turbo-ignore |
| 35 | + |
| 36 | + - name: 🔍 Check for documentation changes |
| 37 | + id: changes |
| 38 | + run: | |
| 39 | + npx turbo-ignore docs |
| 40 | + echo "should_build=$?" >> $GITHUB_OUTPUT |
| 41 | + continue-on-error: true |
| 42 | + |
| 43 | + - name: 📦 Install pnpm |
| 44 | + if: steps.changes.outputs.should_build == '1' |
| 45 | + uses: pnpm/action-setup@v4 |
| 46 | + |
| 47 | + - name: ⎔ Setup Node.js |
| 48 | + if: steps.changes.outputs.should_build == '1' |
| 49 | + uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + node-version: 20 |
| 52 | + cache: 'pnpm' |
| 53 | + |
| 54 | + - name: 🔧 Setup Pages |
| 55 | + if: steps.changes.outputs.should_build == '1' |
| 56 | + uses: actions/configure-pages@v4 |
| 57 | + with: |
| 58 | + # Automatically inject basePath in your Next.js configuration file and disable |
| 59 | + # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). |
| 60 | + # |
| 61 | + # You may remove this line if you want to manage the configuration yourself. |
| 62 | + static_site_generator: next |
| 63 | + |
| 64 | + - name: 📦 Install dependencies |
| 65 | + if: steps.changes.outputs.should_build == '1' |
| 66 | + run: pnpm install --frozen-lockfile |
| 67 | + |
| 68 | + - name: 🏗 Build packages (required for docs) |
| 69 | + if: steps.changes.outputs.should_build == '1' |
| 70 | + run: pnpm turbo run build |
| 71 | + |
| 72 | + - name: 📄 Generate Evolution SDK docs |
| 73 | + if: steps.changes.outputs.should_build == '1' |
| 74 | + run: pnpm turbo run docgen |
| 75 | + working-directory: packages/evolution |
| 76 | + |
| 77 | + - name: 📚 Copy Evolution docs to website |
| 78 | + if: steps.changes.outputs.should_build == '1' |
| 79 | + run: node scripts/copy-evolution-docs.mjs |
| 80 | + working-directory: docs |
| 81 | + |
| 82 | + - name: 🏗 Build documentation with Next.js |
| 83 | + if: steps.changes.outputs.should_build == '1' |
| 84 | + run: pnpm turbo run build |
| 85 | + working-directory: docs |
| 86 | + |
| 87 | + - name: 📤 Upload artifact |
| 88 | + if: steps.changes.outputs.should_build == '1' |
| 89 | + uses: actions/upload-pages-artifact@v3 |
| 90 | + with: |
| 91 | + path: ./docs/out |
| 92 | + |
| 93 | + # Deployment job |
| 94 | + deploy: |
| 95 | + environment: |
| 96 | + name: github-pages |
| 97 | + url: ${{ steps.deployment.outputs.page_url }} |
| 98 | + runs-on: ubuntu-latest |
| 99 | + needs: build |
| 100 | + if: needs.build.outputs.should_build == '1' || github.event_name == 'workflow_dispatch' |
| 101 | + steps: |
| 102 | + - name: 🚀 Deploy to GitHub Pages |
| 103 | + id: deployment |
| 104 | + uses: actions/deploy-pages@v4 |
0 commit comments