Skip to content

Commit 531f21e

Browse files
authored
add sync-docs README (#730)
* add sync-docs README * tweak * link to README
1 parent e425c6a commit 531f21e

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

.github/workflows/sync-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
with:
2525
commit-message: sync ${{ github.event.client_payload.package }} docs
2626
title: Sync `${{ github.event.client_payload.package }}` docs
27-
body: This is an automated pull request
27+
body: This is an automated pull request. See the [README](../tree/main/apps/svelte.dev/scripts/sync-docs/README.md) for more information
2828
branch: sync/${{ github.event.client_payload.package }}
2929
base: main
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# sync-docs
2+
3+
Documentation lives in external repos (at the time of writing, [`sveltejs/svelte`](https://github.com/sveltejs/svelte), [`sveltejs/kit`](https://github.com/sveltejs/kit) and [`sveltejs/cli`](https://github.com/sveltejs/cli), though the plan is to add others) and synced into this repo.
4+
5+
The repos must be cloned (or linked — see [next section](#setup)) into the `apps/svelte.dev/repos` directory.
6+
7+
## Setup
8+
9+
For local development, it's recommended that you symlink the repos, so that you can see changes immediately then open a PR once you're happy with them:
10+
11+
```bash
12+
cd apps/svelte.dev
13+
ln -s /path/to/wherever/you/cloned/sveltejs/svelte repos/svelte
14+
ln -s /path/to/wherever/you/cloned/sveltejs/kit repos/kit
15+
ln -s /path/to/wherever/you/cloned/sveltejs/cli repos/cli
16+
```
17+
18+
I have no idea what the equivalent Windows command would be.
19+
20+
## Syncing
21+
22+
To run the `sync-docs` script locally:
23+
24+
```bash
25+
pnpm sync-docs
26+
```
27+
28+
If you've symlinked the repos and want to watch for changes, you can use the `-w` command:
29+
30+
```bash
31+
pnpm sync-docs -w # or --watch, if you're fancy
32+
```
33+
34+
To pull from the remote first (or clone it, if you don't have it symlinked/cloned locally already):
35+
36+
```bash
37+
pnpm sync-docs -p # or --pull
38+
```
39+
40+
You can combine flags, and specify individual packages:
41+
42+
```bash
43+
pnpm sync-docs -pw kit cli
44+
```
45+
46+
## Automation
47+
48+
Changes to documentation in the source repos will trigger the [`sync-docs.yml`](../../../../.github/workflows/sync-docs.yml) workflow. This is possible because the repos in question have their own `sync-request.yml` workflow that dispatches a request to this repo.
49+
50+
To set up a new repo, create a file in that repo called `.github/workflows/sync-request.yml` with the following contents:
51+
52+
```yml
53+
# https://github.com/sveltejs/svelte.dev/blob/main/apps/svelte.dev/scripts/sync-docs/README.md
54+
name: Dispatch sync request
55+
56+
on:
57+
push:
58+
branches:
59+
- main
60+
61+
jobs:
62+
dispatch:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Repository Dispatch
66+
uses: peter-evans/repository-dispatch@v3
67+
with:
68+
token: ${{ secrets.SYNC_REQUEST_TOKEN }}
69+
repository: sveltejs/svelte.dev
70+
event-type: sync-request
71+
client-payload: |-
72+
{
73+
"package": "<YOUR_PACKAGE_NAME>"
74+
}
75+
```
76+
77+
`YOUR_PACKAGE_NAME` corresponds to the entry in [index.ts](./index.ts).
78+
79+
You will need to add a `SYNC_REQUEST_TOKEN` to the repo. First, create a personal access token by going to https://github.com/settings/personal-access-tokens/new:
80+
81+
- change the 'Resource owner' to `sveltejs`
82+
- provide access to the `sveltejs/svelte.dev` repository
83+
- under 'Repository permissions', change 'Contents' to 'Read and write'
84+
85+
Then, go to `https://github.com/<ORG>/<REPO>/settings/secrets/actions`, click 'New repository secret' and paste in your newly generated personal access token.

0 commit comments

Comments
 (0)