Skip to content

Commit 2ee9eab

Browse files
authored
reinit preview branches from main (#1338)
1 parent 7e48aea commit 2ee9eab

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ jobs:
3939
- uses: actions/checkout@v4
4040
with:
4141
token: ${{ secrets.GH_TOKEN }}
42+
ref: main # Explicitly checkout main branch first
4243
- uses: pnpm/action-setup@v4
4344
- uses: actions/setup-node@v4
4445
with:
4546
node-version: 22
4647
cache: pnpm
4748
- run: pnpm install --frozen-lockfile
4849

49-
- name: Checkout
50-
run: git fetch origin ${{ env.BRANCH }} && git checkout ${{ env.BRANCH }} || git checkout -b ${{ env.BRANCH }}
50+
- name: Create or reset branch from main
51+
run: |
52+
git fetch origin
53+
git checkout -B ${{ env.BRANCH }} # Force create/reset branch based on current main
5154
5255
- name: Sync
5356
run: cd apps/svelte.dev && pnpm sync-docs --owner="${{ inputs.owner }}" -p "${{ inputs.repo }}#${{ inputs.branch }}"
@@ -59,7 +62,7 @@ jobs:
5962
6063
- name: Push
6164
id: push
62-
run: git add -A && git commit -m "sync docs" && git push -u origin ${{ env.BRANCH }}
65+
run: git add -A && git commit -m "sync docs" && git push -u origin ${{ env.BRANCH }} --force
6366

6467
- name: Request preview comment
6568
uses: peter-evans/repository-dispatch@v3

0 commit comments

Comments
 (0)