diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 54d16e2a8..7e09a9177 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -83,18 +83,52 @@ jobs: git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - # Remove all files except .git and _site - find . -maxdepth 1 ! -name '.git' ! -name '.' ! -name '..' ! -name '_site' -exec rm -rf {} + + # Debug: Show current directory contents + echo "=== Before cleanup ===" + ls -la - # Copy built site files to root - cp -r _site/* . - rm -rf _site + # Remove all files except .git and _site (more targeted approach) + shopt -s dotglob + for item in *; do + if [[ "$item" != ".git" && "$item" != "_site" ]]; then + echo "Removing: $item" + rm -rf "$item" + fi + done + shopt -u dotglob + + # Debug: Show directory after cleanup + echo "=== After cleanup ===" + ls -la + + # Debug: Show _site contents + echo "=== _site directory contents ===" + ls -la _site/ + + # Copy built site files to root with verification + if [ -d "_site" ] && [ "$(ls -A _site)" ]; then + echo "Copying _site contents to root..." + cp -rv _site/* . + cp -rv _site/.[^.]* . 2>/dev/null || true # Copy hidden files if they exist + echo "Copy completed. Removing _site directory..." + rm -rf _site + else + echo "Error: _site directory is empty or does not exist" + exit 1 + fi + + # Debug: Show final directory structure + echo "=== Final directory structure ===" + ls -la + echo "=== assets/styles directory ===" + ls -la assets/styles/ || echo "No assets/styles directory found" # Add and commit changes git add -A if git diff --staged --quiet; then echo "No changes to deploy" else + echo "Committing and pushing changes..." git commit -m "CI deploy to gh-pages from publish@${{ github.sha }}" git push origin master fi