Skip to content

Docs preview create #2117

Docs preview create

Docs preview create #2117

name: Docs preview create
on:
workflow_dispatch:
inputs:
repo:
description: 'Repository name (not fully-qualified, eg. `svelte` or `kit`)'
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-${{ inputs.repo }}-${{ inputs.pr }}
jobs:
Sync:
name: Sync
runs-on: ubuntu-latest
concurrency:
group: preview-${{ inputs.repo }}-${{ inputs.pr }} # can't reference env here
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Checkout
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.repo }}#${{ inputs.branch }}"
- name: Configure Git
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- 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 }}"
}