name: Docs Preview on: pull_request: paths: - 'docs/**' concurrency: group: docs-preview-${{ github.event.pull_request.number }} cancel-in-progress: true permissions: contents: read pull-requests: write jobs: preview: runs-on: ubuntu-latest # Skip fork PRs if: github.event.pull_request.head.repo.full_name == github.repository steps: - name: Checkout uses: actions/checkout@v7 with: persist-credentials: false - name: Set up Node.js uses: actions/setup-node@v7 with: node-version: 26.x cache: yarn cache-dependency-path: docs/yarn.lock - name: Install dependencies working-directory: docs run: yarn install --frozen-lockfile - name: Build Docusaurus working-directory: docs run: yarn build - name: Deploy preview to Cloudflare Pages uses: cloudflare/wrangler-action@v4 with: apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} workingDirectory: docs command: pages deploy build --project-name=cleanuparr-docs --branch=pull-${{ github.event.pull_request.number }} - name: Comment preview URL uses: actions/github-script@v9 with: script: | const url = `https://pull-${context.issue.number}.cleanuparr-docs.pages.dev`; const marker = ''; const body = [ marker, `Docs preview for \`${context.payload.pull_request.head.ref}\` (\`${context.payload.pull_request.head.sha.substring(0, 7)}\`):`, ``, `${url}/docs` ].join('\n'); const comments = await github.paginate(github.rest.issues.listComments, { owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, per_page: 100 }); const existing = comments.find(c => c.body.includes(marker)); if (existing) { await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: existing.id, body }); } else { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body }); }