|
| 1 | +name: 🚀 Validation Pipeline |
| 2 | +concurrency: |
| 3 | + group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }} |
| 4 | + cancel-in-progress: true |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + pull_request: |
| 9 | + branches: [main] |
| 10 | + |
| 11 | +permissions: |
| 12 | + actions: write |
| 13 | + contents: read |
| 14 | + # Required to put a comment into the pull-request |
| 15 | + pull-requests: write |
| 16 | +jobs: |
| 17 | + lint: |
| 18 | + name: ⬣ Biome lint |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: ⬇️ Checkout repo |
| 22 | + uses: actions/checkout@v4 |
| 23 | + - name: Setup Biome |
| 24 | + uses: biomejs/setup-biome@v2 |
| 25 | + - name: Run Biome |
| 26 | + run: biome ci . |
| 27 | + |
| 28 | + validate: |
| 29 | + name: 🔎 Validate |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: 🛑 Cancel Previous Runs |
| 33 | + uses: styfle/cancel-workflow-action@0.12.1 |
| 34 | + - name: ⬇️ Checkout repo |
| 35 | + uses: actions/checkout@v4 |
| 36 | + - name: ⎔ Setup node |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version-file: "package.json" |
| 40 | + - name: Install pnpm |
| 41 | + uses: pnpm/action-setup@v4 |
| 42 | + - name: Install dependencies |
| 43 | + run: pnpm install |
| 44 | + - name: Install Playwright browsers |
| 45 | + # downloads browser binaries required by Playwright (Chromium/Firefox/WebKit) |
| 46 | + run: pnpm exec playwright install --with-deps |
| 47 | + - name: 🔎 Validate |
| 48 | + run: pnpm run test |
| 49 | + |
| 50 | + build-docs: |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + ref: ${{ github.head_ref }} |
| 56 | + fetch-depth: 0 |
| 57 | + |
| 58 | + - uses: pnpm/action-setup@v4 |
| 59 | + - uses: actions/setup-node@v4 |
| 60 | + with: |
| 61 | + node-version-file: "package.json" |
| 62 | + cache: pnpm |
| 63 | + |
| 64 | + # One install at the workspace root is enough |
| 65 | + - name: Install deps (root) |
| 66 | + run: pnpm install --prefer-offline --frozen-lockfile |
| 67 | + |
| 68 | + # Decide where the docs app lives: ./docs or . |
| 69 | + - name: Resolve DOCS_DIR |
| 70 | + id: paths |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + if [ -d docs ] && [ -f docs/package.json ]; then |
| 74 | + DOCS_DIR="docs" |
| 75 | + else |
| 76 | + DOCS_DIR="." |
| 77 | + fi |
| 78 | +
|
| 79 | + # expose for later steps |
| 80 | + echo "DOCS_DIR=$DOCS_DIR" >> "$GITHUB_OUTPUT" |
| 81 | +
|
| 82 | + # ok to print within this step using the shell variable |
| 83 | + echo "Using DOCS_DIR=$DOCS_DIR" |
| 84 | +
|
| 85 | + - name: Generate docs |
| 86 | + env: |
| 87 | + APP_ENV: production |
| 88 | + run: pnpm -C "${{ steps.paths.outputs.DOCS_DIR }}" run generate:docs |
| 89 | + |
| 90 | + - name: Pack generated docs (tarball) |
| 91 | + run: | |
| 92 | + OUT_BASE="${{ steps.paths.outputs.DOCS_DIR }}" |
| 93 | + tar -czf docs-generated.tgz -C "$OUT_BASE" generated-docs |
| 94 | + ls -lh docs-generated.tgz |
| 95 | +
|
| 96 | + - name: Upload generated docs (tgz) |
| 97 | + uses: actions/upload-artifact@v4 |
| 98 | + with: |
| 99 | + name: docs-generated-tgz |
| 100 | + path: docs-generated.tgz |
| 101 | + if-no-files-found: error |
| 102 | + |
| 103 | + - name: Upload versions file |
| 104 | + uses: actions/upload-artifact@v4 |
| 105 | + with: |
| 106 | + name: docs-versions |
| 107 | + path: ${{ steps.paths.outputs.DOCS_DIR }}/app/utils/versions.ts |
| 108 | + if-no-files-found: error |
| 109 | + |
| 110 | + deploy-docs-pr-preview: |
| 111 | + if: ${{ github.event_name == 'pull_request' }} |
| 112 | + needs: [lint, validate, build-docs] |
| 113 | + name: Deploy Docs PR Preview |
| 114 | + runs-on: ubuntu-latest |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@v4 |
| 117 | + |
| 118 | + - name: Download generated docs (tgz) |
| 119 | + uses: actions/download-artifact@v4 |
| 120 | + with: |
| 121 | + name: docs-generated-tgz |
| 122 | + path: . |
| 123 | + |
| 124 | + - name: Unpack generated docs into docs/ |
| 125 | + run: | |
| 126 | + set -euxo pipefail |
| 127 | + tar -xzf docs-generated.tgz -C docs |
| 128 | + ls -laR docs/generated-docs | sed -n '1,200p' |
| 129 | + - name: Download versions file |
| 130 | + uses: actions/download-artifact@v4 |
| 131 | + with: |
| 132 | + name: docs-versions |
| 133 | + path: docs/app/utils |
| 134 | + |
| 135 | + - uses: forge-42/fly-deploy@v1.0.0-rc.2 |
| 136 | + id: deploy |
| 137 | + env: |
| 138 | + FLY_ORG: ${{ vars.FLY_ORG }} |
| 139 | + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
| 140 | + FLY_REGION: ${{ vars.FLY_REGION }} |
| 141 | + with: |
| 142 | + workspace_name: docs |
| 143 | + app_name: react-router-devtools-docs-pr-${{ github.event.number }} |
| 144 | + use_isolated_workspace: true |
| 145 | + env_vars: | |
| 146 | + APP_ENV=production |
| 147 | + GITHUB_OWNER=${{ github.repository_owner }} |
| 148 | + GITHUB_REPO=${{ github.event.repository.name }} |
| 149 | + GITHUB_REPO_URL=https://github.com/${{ github.repository }} |
0 commit comments