From b2c8abcea98be306a391ccbacfd44d59f1de336e Mon Sep 17 00:00:00 2001 From: Colin Wu <85907102+ColinWu0403@users.noreply.github.com> Date: Thu, 18 Jul 2024 03:20:01 -0400 Subject: [PATCH] Update static.yml --- .github/workflows/static.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index d60af89..82036d7 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -59,18 +59,21 @@ jobs: git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' - # Initialize a new Git repository in the dist directory - git init - - # Add remote repository - git remote add origin https://github.com/${{ github.repository }}.git - - # Create or switch to the gh-pages branch - git checkout -b gh-pages + # Initialize Git if not already initialized + if [ -z "$(ls -A .git)" ]; then + git init + git remote add origin https://github.com/${{ github.repository }}.git + fi + + # Checkout or create gh-pages branch + git fetch origin gh-pages || git checkout --orphan gh-pages - # Add and commit the build files + # Add all files git add . + + # Commit changes git commit -m "Deploy to GitHub Pages" - # Force push to the gh-pages branch + # Force push to gh-pages branch git push --force origin gh-pages +