From 424c8e2a2d8d0aa7e519803170683335d7df5313 Mon Sep 17 00:00:00 2001 From: "S. Elliott Johnson" Date: Thu, 23 Jan 2025 12:40:20 -0700 Subject: [PATCH 1/4] feat: Remove Rich Harris as commenter on preview comments --- .github/workflows/docs-preview-create.yml | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/.github/workflows/docs-preview-create.yml b/.github/workflows/docs-preview-create.yml index fcbfab0d5..7e7501b51 100644 --- a/.github/workflows/docs-preview-create.yml +++ b/.github/workflows/docs-preview-create.yml @@ -35,26 +35,3 @@ jobs: - name: Push id: push run: git add -A && git commit -m "sync docs" && git push -u origin ${{ env.BRANCH }} - - - name: Find comment - id: fc - uses: peter-evans/find-comment@v3 - with: - token: ${{ secrets.COMMENTER_TOKEN }} - repository: ${{ github.event.client_payload.repo }} - issue-number: ${{ github.event.client_payload.pr }} - comment-author: 'Rich-Harris' # it's using my personal access token, not sure if there's a way to comment as a bot instead - body-includes: _this is an automated message_ - - - name: Create comment - if: steps.fc.outputs.comment-id == '' - uses: peter-evans/create-or-update-comment@v4 - with: - token: ${{ secrets.COMMENTER_TOKEN }} - repository: ${{ github.event.client_payload.repo }} - issue-number: ${{ github.event.client_payload.pr }} - body: | - preview: https://svelte-dev-git-${{ env.BRANCH }}-svelte.vercel.app/ - - _this is an automated message_ - edit-mode: replace From 76bd50039c696cb4fe02cafa01150eb519e25beb Mon Sep 17 00:00:00 2001 From: "S. Elliott Johnson" Date: Thu, 23 Jan 2025 13:00:21 -0700 Subject: [PATCH 2/4] chore: Move to workflow_dispatch, makes more sense --- .github/workflows/docs-preview-create.yml | 24 +++++++++++++++++++---- .github/workflows/docs-preview-delete.yml | 14 ++++++++++--- .github/workflows/sync-docs.yml | 16 +++++++++------ 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docs-preview-create.yml b/.github/workflows/docs-preview-create.yml index 7e7501b51..7f44cbecc 100644 --- a/.github/workflows/docs-preview-create.yml +++ b/.github/workflows/docs-preview-create.yml @@ -1,11 +1,27 @@ name: Docs preview create on: - repository_dispatch: - types: [docs-preview-create] + workflow_dispatch: + inputs: + package: + description: 'Package name' + required: true + type: string + pr: + description: 'PR number' + required: true + type: string + owner: + description: 'Owner (eg. sveltejs)' + required: true + type: string + branch: + description: 'Branch (eg. my-feature-branch)' + required: true + type: string env: - BRANCH: preview-${{ github.event.client_payload.package }}-${{ github.event.client_payload.pr }} + BRANCH: preview-${{ inputs.package }}-${{ inputs.pr }} jobs: Sync: @@ -25,7 +41,7 @@ jobs: run: git fetch origin ${{ env.BRANCH }} && git checkout ${{ env.BRANCH }} || git checkout -b ${{ env.BRANCH }} - name: Sync - 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 }}" + run: cd apps/svelte.dev && pnpm sync-docs --owner="${{ inputs.owner }}" -p "${{ inputs.package }}#${{ inputs.branch }}" - name: Configure Git run: | diff --git a/.github/workflows/docs-preview-delete.yml b/.github/workflows/docs-preview-delete.yml index d9f2a77f4..0fd578f8d 100644 --- a/.github/workflows/docs-preview-delete.yml +++ b/.github/workflows/docs-preview-delete.yml @@ -1,11 +1,19 @@ name: Docs preview delete on: - repository_dispatch: - types: [docs-preview-delete] + workflow_dispatch: + inputs: + package: + description: 'Package name' + required: true + type: string + pr: + description: 'PR number' + required: true + type: string env: - BRANCH: preview-${{ github.event.client_payload.package }}-${{ github.event.client_payload.pr }} + BRANCH: preview-${{ inputs.package }}-${{ inputs.pr }} jobs: Sync: diff --git a/.github/workflows/sync-docs.yml b/.github/workflows/sync-docs.yml index 4c6ba0495..cfb591d11 100644 --- a/.github/workflows/sync-docs.yml +++ b/.github/workflows/sync-docs.yml @@ -1,8 +1,12 @@ name: Sync docs on: - repository_dispatch: - types: [sync-request] + workflow_dispatch: + inputs: + package: + description: 'Package name' + required: true + type: string jobs: Sync: @@ -17,13 +21,13 @@ jobs: - run: pnpm install --frozen-lockfile - name: Sync - run: cd apps/svelte.dev && pnpm sync-docs -p ${{ github.event.client_payload.package }} + run: cd apps/svelte.dev && pnpm sync-docs -p ${{ inputs.package }} - name: Create or update pull request uses: peter-evans/create-pull-request@v7 with: - commit-message: sync ${{ github.event.client_payload.package }} docs - title: Sync `${{ github.event.client_payload.package }}` docs + commit-message: sync ${{ inputs.package }} docs + title: Sync `${{ inputs.package }}` docs body: This is an automated pull request. See the [README](../tree/main/apps/svelte.dev/scripts/sync-docs/README.md) for more information - branch: sync-${{ github.event.client_payload.package }} + branch: sync-${{ inputs.package }} base: main From bb25a73eb945ba37abfb4e112c188dc32550e9fb Mon Sep 17 00:00:00 2001 From: "S. Elliott Johnson" Date: Thu, 23 Jan 2025 16:15:32 -0700 Subject: [PATCH 3/4] chore: name job descriptively --- .github/workflows/docs-preview-create.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs-preview-create.yml b/.github/workflows/docs-preview-create.yml index 7f44cbecc..d1f4cf97f 100644 --- a/.github/workflows/docs-preview-create.yml +++ b/.github/workflows/docs-preview-create.yml @@ -25,6 +25,7 @@ env: jobs: Sync: + name: Sync (preview-${{ inputs.package }}-${{ inputs.pr }}) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 5cdada83be875490238b9c6b89aa758001d43a5a Mon Sep 17 00:00:00 2001 From: "S. Elliott Johnson" Date: Thu, 23 Jan 2025 16:44:42 -0700 Subject: [PATCH 4/4] feat: Rename inputs, use repository dispatch to request comment --- .github/workflows/docs-preview-create.yml | 20 +++++++++++++++----- .github/workflows/docs-preview-delete.yml | 6 +++--- .github/workflows/sync-docs.yml | 12 ++++++------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docs-preview-create.yml b/.github/workflows/docs-preview-create.yml index d1f4cf97f..8ee9ea15b 100644 --- a/.github/workflows/docs-preview-create.yml +++ b/.github/workflows/docs-preview-create.yml @@ -3,8 +3,8 @@ name: Docs preview create on: workflow_dispatch: inputs: - package: - description: 'Package name' + repo: + description: 'Repository name (not fully-qualified, eg. `svelte` or `kit`)' required: true type: string pr: @@ -21,11 +21,11 @@ on: type: string env: - BRANCH: preview-${{ inputs.package }}-${{ inputs.pr }} + BRANCH: preview-${{ inputs.repo }}-${{ inputs.pr }} jobs: Sync: - name: Sync (preview-${{ inputs.package }}-${{ inputs.pr }}) + name: Sync runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -42,7 +42,7 @@ jobs: run: git fetch origin ${{ env.BRANCH }} && git checkout ${{ env.BRANCH }} || git checkout -b ${{ env.BRANCH }} - name: Sync - run: cd apps/svelte.dev && pnpm sync-docs --owner="${{ inputs.owner }}" -p "${{ inputs.package }}#${{ inputs.branch }}" + run: cd apps/svelte.dev && pnpm sync-docs --owner="${{ inputs.owner }}" -p "${{ inputs.repo }}#${{ inputs.branch }}" - name: Configure Git run: | @@ -52,3 +52,13 @@ jobs: - name: Push id: push run: git add -A && git commit -m "sync docs" && git push -u origin ${{ env.BRANCH }} + + - name: Request preview comment + uses: peter-evans/repository-dispatch@v3 + with: + event-type: 'request-preview-comment' + client-payload: |- + { + "repo": "${{ inputs.repo }}", + "pr": "${{ inputs.pr }}", + } diff --git a/.github/workflows/docs-preview-delete.yml b/.github/workflows/docs-preview-delete.yml index 0fd578f8d..faa13fbad 100644 --- a/.github/workflows/docs-preview-delete.yml +++ b/.github/workflows/docs-preview-delete.yml @@ -3,8 +3,8 @@ name: Docs preview delete on: workflow_dispatch: inputs: - package: - description: 'Package name' + repo: + description: 'Repository name (not fully-qualified, eg. `svelte` or `kit`)' required: true type: string pr: @@ -13,7 +13,7 @@ on: type: string env: - BRANCH: preview-${{ inputs.package }}-${{ inputs.pr }} + BRANCH: preview-${{ inputs.repo }}-${{ inputs.pr }} jobs: Sync: diff --git a/.github/workflows/sync-docs.yml b/.github/workflows/sync-docs.yml index cfb591d11..67f0d58db 100644 --- a/.github/workflows/sync-docs.yml +++ b/.github/workflows/sync-docs.yml @@ -3,8 +3,8 @@ name: Sync docs on: workflow_dispatch: inputs: - package: - description: 'Package name' + repo: + description: 'Repository name (not fully-qualified, eg. `svelte` or `kit`)' required: true type: string @@ -21,13 +21,13 @@ jobs: - run: pnpm install --frozen-lockfile - name: Sync - run: cd apps/svelte.dev && pnpm sync-docs -p ${{ inputs.package }} + run: cd apps/svelte.dev && pnpm sync-docs -p ${{ inputs.repo }} - name: Create or update pull request uses: peter-evans/create-pull-request@v7 with: - commit-message: sync ${{ inputs.package }} docs - title: Sync `${{ inputs.package }}` docs + commit-message: sync ${{ inputs.repo }} docs + title: Sync `${{ inputs.repo }}` docs body: This is an automated pull request. See the [README](../tree/main/apps/svelte.dev/scripts/sync-docs/README.md) for more information - branch: sync-${{ inputs.package }} + branch: sync-${{ inputs.repo }} base: main