1
1
name : Docs preview create
2
2
3
3
on :
4
- repository_dispatch :
5
- types : [docs-preview-create]
4
+ workflow_dispatch :
5
+ inputs :
6
+ repo :
7
+ description : ' Repository name (not fully-qualified, eg. `svelte` or `kit`)'
8
+ required : true
9
+ type : string
10
+ pr :
11
+ description : ' PR number'
12
+ required : true
13
+ type : string
14
+ owner :
15
+ description : ' Owner (eg. sveltejs)'
16
+ required : true
17
+ type : string
18
+ branch :
19
+ description : ' Branch (eg. my-feature-branch)'
20
+ required : true
21
+ type : string
6
22
7
23
env :
8
- BRANCH : preview-${{ github.event.client_payload.package }}-${{ github.event.client_payload .pr }}
24
+ BRANCH : preview-${{ inputs.repo }}-${{ inputs .pr }}
9
25
10
26
jobs :
11
27
Sync :
28
+ name : Sync
12
29
runs-on : ubuntu-latest
13
30
steps :
14
31
- uses : actions/checkout@v4
25
42
run : git fetch origin ${{ env.BRANCH }} && git checkout ${{ env.BRANCH }} || git checkout -b ${{ env.BRANCH }}
26
43
27
44
- name : Sync
28
- run : cd apps/svelte.dev && pnpm sync-docs --owner="${{ github.event.client_payload. owner }}" -p "${{ github.event.client_payload.package }}#${{ github.event.client_payload .branch }}"
45
+ run : cd apps/svelte.dev && pnpm sync-docs --owner="${{ inputs. owner }}" -p "${{ inputs.repo }}#${{ inputs .branch }}"
29
46
30
47
- name : Configure Git
31
48
run : |
@@ -36,25 +53,12 @@ jobs:
36
53
id : push
37
54
run : git add -A && git commit -m "sync docs" && git push -u origin ${{ env.BRANCH }}
38
55
39
- - name : Find comment
40
- id : fc
41
- uses : peter-evans/find-comment@v3
56
+ - name : Request preview comment
57
+ uses : peter-evans/repository-dispatch@v3
42
58
with :
43
- token : ${{ secrets.COMMENTER_TOKEN }}
44
- repository : ${{ github.event.client_payload.repo }}
45
- issue-number : ${{ github.event.client_payload.pr }}
46
- comment-author : ' Rich-Harris' # it's using my personal access token, not sure if there's a way to comment as a bot instead
47
- body-includes : _this is an automated message_
48
-
49
- - name : Create comment
50
- if : steps.fc.outputs.comment-id == ''
51
- uses : peter-evans/create-or-update-comment@v4
52
- with :
53
- token : ${{ secrets.COMMENTER_TOKEN }}
54
- repository : ${{ github.event.client_payload.repo }}
55
- issue-number : ${{ github.event.client_payload.pr }}
56
- body : |
57
- preview: https://svelte-dev-git-${{ env.BRANCH }}-svelte.vercel.app/
58
-
59
- _this is an automated message_
60
- edit-mode : replace
59
+ event-type : ' request-preview-comment'
60
+ client-payload : |-
61
+ {
62
+ "repo": "${{ inputs.repo }}",
63
+ "pr": "${{ inputs.pr }}",
64
+ }
0 commit comments