Skip to content

Commit e5f237e

Browse files
Copilotpubkey
andauthored
ci: publish docs only on manual trigger and release (#8502)
* feat: move docs build output to docs branch instead of committing to master Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/ed54ade7-5c8f-47ca-8752-60fbeabb1bbd Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com> * chore: clarify git fetch error suppression comment in build workflow Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/ed54ade7-5c8f-47ca-8752-60fbeabb1bbd Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com> * ci: publish docs only on manual run and release Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/0fd6e292-31df-491e-af39-f322c9b8697b Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com> * docs: align contribute guide with manual/release docs publishing Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/0fd6e292-31df-491e-af39-f322c9b8697b Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com> * docs: remove docs publishing note from contribute.md Agent-Logs-Url: https://github.com/pubkey/rxdb/sessions/d4b1eaa0-3b75-4d39-9035-8433584955c7 Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pubkey <8926560+pubkey@users.noreply.github.com>
1 parent 606f4c7 commit e5f237e

845 files changed

Lines changed: 53 additions & 104264 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
# This is a basic workflow to help you get started with Actions
1+
name: Publish Docs
22

3-
name: build and push
4-
5-
# Controls when the action will run.
63
on:
7-
# Allows you to run this workflow manually from the Actions tab
4+
# Allow manual triggering from the Actions tab
85
workflow_dispatch:
6+
# Run automatically when a GitHub release is published
7+
release:
8+
types: [published]
9+
10+
permissions:
11+
contents: write
912

1013
jobs:
11-
# This workflow contains a single job called "build"
12-
build-all:
13-
# The type of runner that the job will run on
14+
publish-docs:
1415
runs-on: ubuntu-22.04
1516

16-
# Steps represent a sequence of tasks that will be executed as part of the job
1717
steps:
18-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
1918
- uses: actions/checkout@v6
19+
with:
20+
# Always build docs from the source branch
21+
ref: master
22+
# Fetch full history so per-file "Last updated" timestamps are accurate
23+
fetch-depth: 0
2024

2125
- name: Setup Node.js environment
2226
uses: actions/setup-node@v6.4.0
@@ -25,28 +29,41 @@ jobs:
2529

2630
- name: install npm dependencies
2731
run: npm install || (sleep 15 && npm install) || (sleep 15 && npm install)
28-
32+
2933
- name: build code
3034
run: npm run build
31-
35+
36+
- name: install docs dependencies
37+
run: (cd docs-src && (npm install || (sleep 15 && npm install) || (sleep 15 && npm install)))
38+
39+
- name: generate headers
40+
run: npm run generate:headers
41+
3242
- name: build docs
33-
run: |
34-
(cd docs-src && (npm install || (sleep 15 && npm install) || (sleep 15 && npm install)))
35-
npm run generate:headers
36-
npm run docs:build
43+
run: npm run docs:build
3744

38-
- name: Commit files
45+
- name: Publish docs to the docs branch
3946
run: |
40-
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
41-
git config --local user.name "github-actions[bot]"
42-
git add .
43-
git commit -m "BUILD" -a
47+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
48+
git config user.name "github-actions[bot]"
4449
45-
- name: Push changes
46-
uses: ad-m/github-push-action@master
47-
with:
48-
github_token: ${{ secrets.GITHUB_TOKEN }}
49-
branch: ${{ github.ref }}
50+
# Try to fetch the existing docs branch; suppress errors because it may not exist yet
51+
# on first run (the worktree add --orphan path handles that case).
52+
git fetch origin docs:docs 2>/dev/null || true
53+
git worktree add /tmp/docs-branch docs 2>/dev/null || \
54+
git worktree add --orphan /tmp/docs-branch docs
55+
56+
# Wipe everything that was previously in the docs branch
57+
rm -rf /tmp/docs-branch/*
58+
59+
# Copy the fresh build output
60+
cp -r docs-src/build/. /tmp/docs-branch/
61+
62+
cd /tmp/docs-branch
63+
git add -A
64+
# Only commit when something actually changed
65+
git diff --cached --quiet || git commit -m "docs: publish from ${{ github.sha }}"
66+
git push origin HEAD:docs
5067
5168
- name: notify bing indexnow
5269
run: npm run docs:notify-indexnow
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Deploy To Cloudflare Pages
22

33
on:
4+
# Trigger automatically after docs are published to the docs branch
5+
push:
6+
branches: [docs]
47
workflow_dispatch:
58

69
jobs:
@@ -9,9 +12,11 @@ jobs:
912
name: Deploy
1013
steps:
1114
- uses: actions/checkout@v6
15+
with:
16+
ref: docs
1217
- name: Deploy to Cloudflare Pages
1318
uses: cloudflare/wrangler-action@v3
1419
with:
1520
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
1621
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
17-
command: pages deploy docs --project-name=rxdb
22+
command: pages deploy . --project-name=rxdb

.github/workflows/prevent-commit-to-generated.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ on:
55
pull_request:
66
paths:
77
- 'dist/**'
8-
- 'docs/**'
98

109
jobs:
1110
warn-user:
1211
runs-on: ubuntu-22.04
1312
steps:
1413
- uses: actions/checkout@v6
1514
- name: Warn User to not commit generated files
16-
run: bash -c 'echo "You have commited generated files (from the dist or docs folder), this is not allowed. You can only commit files that you have manually edited" && exit 1'
15+
run: bash -c 'echo "You have commited generated files (from the dist folder), this is not allowed. You can only commit files that you have manually edited" && exit 1'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ plugins/
3030
ai-context.txt
3131
ERROR-MESSAGES.md
3232
.chrome-profile-perf/
33+
/docs/

docs-src/docs/contribute.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ To read the docs locally, run `npm run docs:install && npm run docs:serve` and o
5454

5555

5656

57+
5758
# Thank you for contributing!
File renamed without changes.

docs/404.html

Lines changed: 0 additions & 40 deletions
This file was deleted.

docs/CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)