From b0d284814da5f6d336b2da0edd5680aed9948758 Mon Sep 17 00:00:00 2001 From: jefino9488 Date: Sun, 26 Apr 2026 22:29:48 +0530 Subject: [PATCH] fix(ci): ensure gh-pages branch initialization in workflows Co-authored-by: Junie --- .github/workflows/release-engine.yml | 25 ++++++++++++++++++------ .github/workflows/update-build-index.yml | 23 +++++++++++++++++----- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-engine.yml b/.github/workflows/release-engine.yml index 26b9fb1..dd2ea00 100644 --- a/.github/workflows/release-engine.yml +++ b/.github/workflows/release-engine.yml @@ -68,11 +68,24 @@ jobs: make_latest: true generate_release_notes: false - - name: Checkout gh-pages - uses: actions/checkout@v4 - with: - ref: gh-pages - path: gh-pages + - name: Setup gh-pages + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + if git fetch origin gh-pages; then + git clone --branch gh-pages --depth 1 https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages + else + echo "gh-pages branch not found, initializing..." + mkdir -p gh-pages + cd gh-pages + git init + git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git + git checkout -b gh-pages + touch .gitkeep + git add .gitkeep + git commit -m "Initialize gh-pages" + cd .. + fi - name: Update latest stable JSON run: | @@ -97,5 +110,5 @@ jobs: echo "No latest.json changes to commit" else git commit -m "Update latest stable to v${{ github.event.inputs.version }}" - git push + git push origin gh-pages fi diff --git a/.github/workflows/update-build-index.yml b/.github/workflows/update-build-index.yml index 2fb5ef0..f74b168 100644 --- a/.github/workflows/update-build-index.yml +++ b/.github/workflows/update-build-index.yml @@ -23,11 +23,24 @@ jobs: permissions: contents: write steps: - - name: Checkout gh-pages + - name: Checkout repository uses: actions/checkout@v4 - with: - ref: gh-pages - fetch-depth: 1 + + - name: Setup gh-pages branch + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + if git fetch origin gh-pages; then + git checkout -B gh-pages origin/gh-pages + else + echo "gh-pages branch not found, creating orphan branch..." + git checkout --orphan gh-pages + git rm -rf . + mkdir -p builds + touch builds/.gitkeep + git add builds/.gitkeep + git commit -m "Initialize gh-pages" + fi - name: Download build manifest artifact uses: actions/download-artifact@v4 @@ -154,5 +167,5 @@ jobs: echo "No changes to commit" else git commit -m "Update build index for run ${{ github.event.workflow_run.id }}" - git push + git push origin gh-pages fi