name: Sync Versioned Documentation on: workflow_run: workflows: - Release types: - completed branches: # Match editBranch values with a pinned commitSha in `docs/lib/docs-version-sources.json`. - "v*.*.x" permissions: contents: read concurrency: group: sync-version-docs-${{ github.event.workflow_run.head_branch }} cancel-in-progress: true jobs: sync: if: > github.repository_owner == 'better-auth' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.conclusion == 'success' && vars.RELEASE_APP_ID != '' runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: ref: main persist-credentials: false - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version-file: ".nvmrc" package-manager-cache: false - name: Update documentation source id: update env: SOURCE_BRANCH: ${{ github.event.workflow_run.head_branch }} SOURCE_SHA: ${{ github.event.workflow_run.head_sha }} run: node docs/scripts/update-docs-version-source.ts "$SOURCE_BRANCH" "$SOURCE_SHA" >> "$GITHUB_OUTPUT" - name: Check source changes id: changes if: steps.update.outputs.changed == 'true' env: PREVIOUS_SHA: ${{ steps.update.outputs.previous_sha }} SOURCE_SHA: ${{ github.event.workflow_run.head_sha }} run: | git fetch --quiet --no-tags --depth=1 origin "$PREVIOUS_SHA" "$SOURCE_SHA" CHANGED_FILES=$(git diff --name-only "$PREVIOUS_SHA" "$SOURCE_SHA" -- \ docs/content/docs \ packages/better-auth/package.json) if [ -n "$CHANGED_FILES" ]; then echo "relevant=true" >> "$GITHUB_OUTPUT" else echo "relevant=false" >> "$GITHUB_OUTPUT" fi - name: Generate App Token id: app-token if: steps.changes.outputs.relevant == 'true' uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 with: app-id: ${{ vars.RELEASE_APP_ID }} private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} permission-contents: write permission-pull-requests: write - name: Create or update draft PR if: steps.changes.outputs.relevant == 'true' uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: token: ${{ steps.app-token.outputs.token }} base: main branch: docs-sync/${{ github.event.workflow_run.head_branch }} add-paths: docs/lib/docs-version-sources.json commit-message: "docs: sync v${{ steps.update.outputs.release_line }} documentation" sign-commits: true title: "docs: sync v${{ steps.update.outputs.release_line }} documentation" draft: always-true body: | Updates the v${{ steps.update.outputs.release_line }} documentation snapshot after changes landed on `${{ github.event.workflow_run.head_branch }}`. - Source revision: [`${{ github.event.workflow_run.head_sha }}`](https://github.com/${{ github.repository }}/commit/${{ github.event.workflow_run.head_sha }}) - Compare: [Compare with the current snapshot](https://github.com/${{ github.repository }}/compare/${{ steps.update.outputs.previous_sha }}...${{ github.event.workflow_run.head_sha }}) Review the source changes and documentation preview, then merge this PR when ready.