Skip to content

Commit c892d21

Browse files
committed
Update publish workflow
1 parent 7fa921e commit c892d21

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ concurrency:
1111
group: docs
1212
cancel-in-progress: true
1313

14+
permissions:
15+
contents: write
16+
1417
jobs:
1518
build-and-deploy:
1619
runs-on: ubuntu-latest
@@ -105,18 +108,26 @@ jobs:
105108
run: |
106109
jq -s '.[0] + .[1]' _site/search_original.json fixed_main_search.json > _site/search.json
107110
108-
- name: Deploy versioned docs
109-
uses: JamesIves/github-pages-deploy-action@v4
111+
- name: Checkout gh-pages branch
112+
uses: actions/checkout@v4
110113
with:
111-
branch: gh-pages
112-
folder: _site
113-
target-folder: versions/${{ env.version }}
114-
clean: false
114+
ref: gh-pages
115+
path: ../gh-pages
115116

116-
- name: Deploy latest docs to root
117-
if: env.version == env.LATEST
118-
uses: JamesIves/github-pages-deploy-action@v4
119-
with:
120-
branch: gh-pages
121-
folder: _site
122-
clean: false
117+
- name: Update gh-pages branch
118+
run: |
119+
# Copy to versions/ subdirectory
120+
mkdir -p ../gh-pages/versions/${{ env.version }}
121+
cp -r _site/* ../gh-pages/versions/${{ env.version }}
122+
123+
# Find the latest version of the docs and copy that to the root
124+
cd ../gh-pages/versions
125+
LATEST_DOCS=$(ls -d * | sort -V | tail -n 1)
126+
cp -r $LATEST_DOCS/* ../
127+
128+
# Commit and push
129+
git config --global user.name "github-actions[bot]"
130+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
131+
git add .
132+
git commit -m "Publish docs @ ${GITHUB_REPOSITORY}@${GITHUB_SHA}"
133+
git push

0 commit comments

Comments
 (0)