|
20 | 20 | with: |
21 | 21 | fetch-depth: 0 |
22 | 22 |
|
23 | | - - uses: actions/checkout@v4 |
24 | | - with: |
25 | | - ref: gh-pages |
26 | | - fetch-depth: 0 |
27 | | - path: gh-pages |
28 | | - |
29 | 23 | - name: Download artifacts |
30 | 24 | uses: actions/github-script@v7 |
31 | 25 | with: |
@@ -80,39 +74,39 @@ jobs: |
80 | 74 |
|
81 | 75 | - name: Commit and push to gh-pages |
82 | 76 | run: | |
83 | | - cd gh-pages |
84 | | - # configure committer |
| 77 | + # Configure git |
85 | 78 | git config --global user.name "github-actions[bot]" |
86 | 79 | 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 |
93 | 85 | 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 |
95 | 90 | fi |
96 | | -
|
97 | | - # clean working directory completely |
98 | | - git rm -rf . 2>/dev/null || true |
| 91 | + |
| 92 | + # Clean the working directory |
99 | 93 | 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 |
106 | 94 | |
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 |
108 | 102 | echo "Files to commit:" |
109 | 103 | ls -la |
110 | 104 | echo "Releases directory:" |
111 | 105 | ls -R releases/ || echo "No releases found" |
112 | | -
|
113 | | - # commit and push |
| 106 | + |
| 107 | + # Commit and push |
114 | 108 | git add -A |
115 | | - if git diff --staged --quiet; then |
| 109 | + if git diff --staged --quiet 2>/dev/null; then |
116 | 110 | echo "No changes to commit" |
117 | 111 | else |
118 | 112 | git commit -m "docs: publish artifacts from ${{ github.sha }} to GitHub Pages" |
|
0 commit comments