Skip to content

Commit 7f482b4

Browse files
committed
fix: fixes of the gh pages commit
Signed-off-by: Abinand P <abinand0911@gmail.com>
1 parent aea2456 commit 7f482b4

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

.github/workflows/publish-pages.yml

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23-
- uses: actions/checkout@v4
24-
with:
25-
ref: gh-pages
26-
fetch-depth: 0
27-
path: gh-pages
28-
2923
- name: Download artifacts
3024
uses: actions/github-script@v7
3125
with:
@@ -80,39 +74,39 @@ jobs:
8074
8175
- name: Commit and push to gh-pages
8276
run: |
83-
cd gh-pages
84-
# configure committer
77+
# Configure git
8578
git config --global user.name "github-actions[bot]"
8679
git config --global user.email "github-actions[bot]@users.noreply.github.com"
87-
88-
# ensure we have the latest gh-pages branch
89-
git fetch origin gh-pages || git checkout --orphan gh-pages
90-
91-
# if gh-pages exists, check it out; otherwise stay on orphan branch
92-
if git rev-parse --verify origin/gh-pages >/dev/null 2>&1; then
80+
81+
# Check if gh-pages branch exists on remote
82+
if git ls-remote --heads origin gh-pages | grep gh-pages; then
83+
echo "gh-pages branch exists, checking it out..."
84+
git fetch origin gh-pages
9385
git checkout gh-pages
94-
git reset --hard origin/gh-pages
86+
else
87+
echo "gh-pages branch doesn't exist, creating orphan branch..."
88+
git checkout --orphan gh-pages
89+
git rm -rf . 2>/dev/null || true
9590
fi
96-
97-
# clean working directory completely
98-
git rm -rf . 2>/dev/null || true
91+
92+
# Clean the working directory
9993
rm -rf * .* 2>/dev/null || true
100-
101-
# copy generated site files into the gh-pages checkout
102-
cp -r ../releases . || mkdir -p releases
103-
cp ../install.sh . 2>/dev/null || true
104-
cp ../index.html . 2>/dev/null || true
105-
cp ../manifest.json . 2>/dev/null || true
10694
107-
# show what we're about to commit
95+
# Copy generated site files
96+
cp -r releases . || mkdir -p releases
97+
cp install.sh . 2>/dev/null || true
98+
cp index.html . 2>/dev/null || true
99+
cp manifest.json . 2>/dev/null || true
100+
101+
# Show what we're about to commit
108102
echo "Files to commit:"
109103
ls -la
110104
echo "Releases directory:"
111105
ls -R releases/ || echo "No releases found"
112-
113-
# commit and push
106+
107+
# Commit and push
114108
git add -A
115-
if git diff --staged --quiet; then
109+
if git diff --staged --quiet 2>/dev/null; then
116110
echo "No changes to commit"
117111
else
118112
git commit -m "docs: publish artifacts from ${{ github.sha }} to GitHub Pages"

0 commit comments

Comments
 (0)