From 9505132aaf3c1457383040f5356f6c1d9d4296d0 Mon Sep 17 00:00:00 2001 From: SaelixCode Date: Mon, 23 Mar 2026 00:09:31 -0400 Subject: [PATCH] fix(ci): fix sync-docs empty-repo crash and update-screenshots protected-branch push update-screenshots: replace direct git push to develop (blocked by branch protection) with peter-evans/create-pull-request@v6, which opens or updates a chore/refresh-screenshots PR instead. sync-docs: add continue-on-error on the sencho-docs checkout so an empty repo doesn't abort the job. A new init step runs git init -b main and re-adds the remote when .git is missing. Final push uses git push origin HEAD:main to work on both first-run (empty repo) and subsequent runs (existing branch). --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++-------- CHANGELOG.md | 4 ++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97fd72f5..87c3f121 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -223,13 +223,16 @@ jobs: E2E_USERNAME: admin E2E_PASSWORD: password123 - - name: Commit updated screenshots - run: | - git config user.email "docs-bot@sencho.io" - git config user.name "Sencho Docs Bot" - git add docs/images/ - git commit -m "docs: refresh screenshots" || echo "No changes to commit" - git push + - name: Open / update screenshots PR + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: chore/refresh-screenshots + commit-message: "docs: refresh screenshots" + title: "docs: refresh screenshots" + body: "Automated screenshot refresh — generated by the `update-screenshots` CI job on every push to `develop`." + add-paths: docs/images/ + delete-branch: true sync-docs: runs-on: ubuntu-latest @@ -246,6 +249,18 @@ jobs: repository: AnsoCode/sencho-docs token: ${{ secrets.DOCS_REPO_TOKEN }} path: sencho-docs + # An empty repo (no commits yet) will fail the checkout — handled below + continue-on-error: true + + - name: Initialize sencho-docs if repo is empty + run: | + if [ ! -d "sencho-docs/.git" ]; then + echo "sencho-docs has no .git — initializing fresh repo" + mkdir -p sencho-docs + cd sencho-docs + git init -b main + git remote add origin "https://x-access-token:${{ secrets.DOCS_REPO_TOKEN }}@github.com/AnsoCode/sencho-docs.git" + fi - name: Copy /docs into sencho-docs root run: rsync -av --delete sencho/docs/ sencho-docs/ @@ -258,4 +273,4 @@ jobs: git config user.name "Sencho Docs Bot" git add -A git commit -m "docs: sync from develop@${{ github.sha }}" || echo "No changes to commit" - git push + git push origin HEAD:main diff --git a/CHANGELOG.md b/CHANGELOG.md index af7a20ae..3dda4198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- fix(ci): `update-screenshots` was pushing directly to the protected `develop` branch; replaced the `git push` step with `peter-evans/create-pull-request@v6` which opens/updates a `chore/refresh-screenshots` PR instead +- fix(ci): `sync-docs` failed with `fatal: not in a git directory` when `sencho-docs` is empty (no commits); added `continue-on-error: true` on the checkout step plus a fallback `git init -b main` with remote re-add, then pushes with `git push origin HEAD:main` to create the branch on first run + ### Added - feat: automated documentation pipeline with Mintlify sync - feat: CI job to auto-refresh doc screenshots on every develop push