Skip to content

Commit ae3ead0

Browse files
feat: Remove Rich Harris as commenter on preview comments (#1120)
* feat: Remove Rich Harris as commenter on preview comments * chore: Move to workflow_dispatch, makes more sense * chore: name job descriptively * feat: Rename inputs, use repository dispatch to request comment
1 parent d160b19 commit ae3ead0

File tree

3 files changed

+50
-34
lines changed

3 files changed

+50
-34
lines changed
+29-25
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
name: Docs preview create
22

33
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
622

723
env:
8-
BRANCH: preview-${{ github.event.client_payload.package }}-${{ github.event.client_payload.pr }}
24+
BRANCH: preview-${{ inputs.repo }}-${{ inputs.pr }}
925

1026
jobs:
1127
Sync:
28+
name: Sync
1229
runs-on: ubuntu-latest
1330
steps:
1431
- uses: actions/checkout@v4
@@ -25,7 +42,7 @@ jobs:
2542
run: git fetch origin ${{ env.BRANCH }} && git checkout ${{ env.BRANCH }} || git checkout -b ${{ env.BRANCH }}
2643

2744
- 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 }}"
2946

3047
- name: Configure Git
3148
run: |
@@ -36,25 +53,12 @@ jobs:
3653
id: push
3754
run: git add -A && git commit -m "sync docs" && git push -u origin ${{ env.BRANCH }}
3855

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
4258
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+
}

.github/workflows/docs-preview-delete.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
name: Docs preview delete
22

33
on:
4-
repository_dispatch:
5-
types: [docs-preview-delete]
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
614

715
env:
8-
BRANCH: preview-${{ github.event.client_payload.package }}-${{ github.event.client_payload.pr }}
16+
BRANCH: preview-${{ inputs.repo }}-${{ inputs.pr }}
917

1018
jobs:
1119
Sync:

.github/workflows/sync-docs.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
name: Sync docs
22

33
on:
4-
repository_dispatch:
5-
types: [sync-request]
4+
workflow_dispatch:
5+
inputs:
6+
repo:
7+
description: 'Repository name (not fully-qualified, eg. `svelte` or `kit`)'
8+
required: true
9+
type: string
610

711
jobs:
812
Sync:
@@ -17,13 +21,13 @@ jobs:
1721
- run: pnpm install --frozen-lockfile
1822

1923
- name: Sync
20-
run: cd apps/svelte.dev && pnpm sync-docs -p ${{ github.event.client_payload.package }}
24+
run: cd apps/svelte.dev && pnpm sync-docs -p ${{ inputs.repo }}
2125

2226
- name: Create or update pull request
2327
uses: peter-evans/create-pull-request@v7
2428
with:
25-
commit-message: sync ${{ github.event.client_payload.package }} docs
26-
title: Sync `${{ github.event.client_payload.package }}` docs
29+
commit-message: sync ${{ inputs.repo }} docs
30+
title: Sync `${{ inputs.repo }}` docs
2731
body: This is an automated pull request. See the [README](../tree/main/apps/svelte.dev/scripts/sync-docs/README.md) for more information
28-
branch: sync-${{ github.event.client_payload.package }}
32+
branch: sync-${{ inputs.repo }}
2933
base: main

0 commit comments

Comments
 (0)