|
| 1 | +name: Generate Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + generate-docs: |
| 10 | + if: github.run_number != 1 && github.event.repository.owner.login == 'react18-tools' |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + ref: ${{ github.event.before }} |
| 19 | + |
| 20 | + - name: Check if package.json was modified |
| 21 | + id: pub |
| 22 | + run: | |
| 23 | + git fetch origin main && git checkout main |
| 24 | + if git diff --name-only ${{ github.event.before }} HEAD | grep -q "lib/package.json"; then |
| 25 | + echo "file_changed=true" >> $GITHUB_ENV |
| 26 | + else |
| 27 | + echo "file_changed=false" >> $GITHUB_ENV |
| 28 | + fi |
| 29 | +
|
| 30 | + - name: Exit early if lib/package.json was modified |
| 31 | + if: env.file_changed == 'true' |
| 32 | + run: exit 0 |
| 33 | + |
| 34 | + - uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + registry-url: https://registry.npmjs.org |
| 37 | + node-version: 20 |
| 38 | + - name: Setup Git |
| 39 | + run: | |
| 40 | + git config --global user.name "mayank1513" |
| 41 | + git config --global user.email "[email protected]" |
| 42 | + git fetch |
| 43 | + git checkout main |
| 44 | + git pull |
| 45 | + - run: npm i -g pnpm && pnpm i --no-frozen-lockfile |
| 46 | + name: Install dependencies |
| 47 | + - run: git stash --include-untracked |
| 48 | + name: clean up working directory |
| 49 | + - name: Generate/update docs |
| 50 | + run: | |
| 51 | + pnpm doc && pnpm format |
| 52 | + echo "$(git rev-parse HEAD)" > .turborepo-template.lst |
| 53 | + - name: Save docs back to repo |
| 54 | + run: git add . && git commit -m "upgrade deps && docs [skip ci]" && git push origin main |
| 55 | + - name: Update website |
| 56 | + continue-on-error: true |
| 57 | + run: | |
| 58 | + gh api \ |
| 59 | + --method POST \ |
| 60 | + -H "Accept: application/vnd.github+json" \ |
| 61 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 62 | + /repos/mayank1513/turborepo-template/merge-upstream \ |
| 63 | + -f "branch=main" |
| 64 | + env: |
| 65 | + GH_TOKEN: ${{ secrets.mayank1513PAT }} |
0 commit comments