mirror of
https://github.com/marceloprates/prettymaps.git
synced 2025-08-30 17:50:13 +02:00
Enhance GitHub Actions workflow to handle orphan branch creation and prevent unnecessary commits for site updates.
This commit is contained in:
20
.github/workflows/docs.yml
vendored
20
.github/workflows/docs.yml
vendored
@@ -34,10 +34,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config --global user.name "github-actions[bot]"
|
git config --global user.name "github-actions[bot]"
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git fetch origin site-artifact || true
|
# Create orphan branch or switch to it
|
||||||
git switch --orphan site-artifact
|
git checkout --orphan site-artifact
|
||||||
git rm -rf .
|
# Remove all files (tracked and untracked)
|
||||||
|
git rm -rf . || true
|
||||||
|
rm -rf *
|
||||||
|
# Copy site output to root
|
||||||
cp -r site/* .
|
cp -r site/* .
|
||||||
|
# Add a .nojekyll file to prevent GitHub Pages from ignoring files/folders starting with _
|
||||||
|
touch .nojekyll
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Update built site from main"
|
# Only commit if there are files to commit
|
||||||
git push --force origin site-artifact
|
if git diff --cached --quiet; then
|
||||||
|
echo 'No changes to commit'
|
||||||
|
else
|
||||||
|
git commit -m "Update built site from main"
|
||||||
|
git push --force origin site-artifact
|
||||||
|
fi
|
Reference in New Issue
Block a user