|
| 1 | +name: 📚 Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + # Enable main after the next release beyond `7.7.0` |
| 7 | + # - main |
| 8 | + - dev |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + branch: |
| 12 | + description: "Branch to generate docs for (usually dev)" |
| 13 | + required: true |
| 14 | + api: |
| 15 | + description: "API Names to generate docs for" |
| 16 | + required: false |
| 17 | + default: "" |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + docs: |
| 25 | + if: github.repository == 'remix-run/react-router' |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: ⬇️ Checkout repo |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + token: ${{ secrets.FORMAT_PAT }} |
| 33 | + ref: ${{ github.event.inputs.branch }} |
| 34 | + |
| 35 | + - name: 📦 Setup pnpm |
| 36 | + uses: pnpm/action-setup@v4 |
| 37 | + |
| 38 | + - name: ⎔ Setup node |
| 39 | + uses: actions/setup-node@v4 |
| 40 | + with: |
| 41 | + node-version-file: ".nvmrc" |
| 42 | + cache: pnpm |
| 43 | + |
| 44 | + - name: 📥 Install deps |
| 45 | + run: pnpm install --frozen-lockfile |
| 46 | + |
| 47 | + - name: 🏗 Build |
| 48 | + run: pnpm build |
| 49 | + |
| 50 | + - name: 📚 Generate Typedoc Docs |
| 51 | + run: pnpm run docs |
| 52 | + |
| 53 | + - name: 📚 Generate Markdown Docs (for all APIs) |
| 54 | + if: github.event.inputs.api == '' |
| 55 | + run: node --experimental-strip-types scripts/docs.ts --path packages/react-router/lib/hooks.tsx --write |
| 56 | + |
| 57 | + - name: 📚 Generate Markdown Docs (for specific APIs) |
| 58 | + if: github.event.inputs.api != '' |
| 59 | + run: node --experimental-strip-types scripts/docs.ts --path packages/react-router/lib/hooks.tsx --write --api ${{ github.event.inputs.api }} |
| 60 | + |
| 61 | + - name: 💪 Commit |
| 62 | + run: | |
| 63 | + git config --local user.email "[email protected]" |
| 64 | + git config --local user.name "Remix Run Bot" |
| 65 | +
|
| 66 | + git add . |
| 67 | + if [ -z "$(git status --porcelain)" ]; then |
| 68 | + echo "💿 no docs changed" |
| 69 | + exit 0 |
| 70 | + fi |
| 71 | + git commit -m "chore: generate markdown docs from jsdocs" |
| 72 | + git push |
| 73 | + echo "💿 pushed docs changes https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)" |
0 commit comments