Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .github/actions/deploy-to-gh-pages/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,39 @@ inputs:
outputs:
url:
description: Default GitHub Pages URL for the deployed subdirectory
value: ${{ steps.deploy.outputs.url }}
value: ${{ steps.url.outputs.url }}

runs:
using: composite
steps:
- id: deploy
shell: bash
# Create a worktree for gh-pages.
- shell: bash
run: |
TARGET="${{ inputs.target }}"
git fetch origin gh-pages 2>/dev/null || true
if git rev-parse --verify origin/gh-pages >/dev/null 2>&1; then
git checkout -B gh-pages origin/gh-pages
git worktree add /tmp/gh-pages gh-pages
else
git checkout --orphan gh-pages
git rm -rf .
git clean -fd
git worktree add --orphan -b gh-pages /tmp/gh-pages
fi

# Copy the built site into the target subdirectory, commit, and push.
- shell: bash
run: |
cd /tmp/gh-pages
TARGET="${{ inputs.target }}"
rm -rf "$TARGET"
mkdir -p "$(dirname "$TARGET")"
cp -r "${{ inputs.site-dir }}" "$TARGET"
touch .nojekyll
git add .nojekyll "$TARGET"
git diff --cached --quiet || git commit -m "${{ inputs.commit-message }}"
git push origin gh-pages
echo "url=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${TARGET}/" >> "$GITHUB_OUTPUT"

# Clean up the worktree.
- shell: bash
run: git worktree remove /tmp/gh-pages

# Output the default GitHub Pages URL for the deployed subdirectory.
- id: url
shell: bash
run: echo "url=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ inputs.target }}/" >> "$GITHUB_OUTPUT"
10 changes: 10 additions & 0 deletions .github/actions/update-index/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ inputs:
runs:
using: composite
steps:
# Create a worktree for gh-pages.
- shell: bash
run: git worktree add /tmp/gh-pages gh-pages

# Generate index.html, commit, and push.
- shell: bash
run: |
cd /tmp/gh-pages
python "${{ github.action_path }}/generate_index.py" \
"${{ inputs.repo-name }}" \
"${{ inputs.repo-url }}"
git add index.html
git diff --cached --quiet || git commit -m "Update index.html"
git push origin gh-pages

# Clean up the worktree.
- shell: bash
run: git worktree remove /tmp/gh-pages
5 changes: 5 additions & 0 deletions .github/workflows/docs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ jobs:

- name: Update latest
run: |
git worktree add /tmp/gh-pages gh-pages
cd /tmp/gh-pages
rm -rf latest
cp -r "${{ steps.build.outputs.site-dir }}" latest
git add latest
git commit -m "Update latest"
git push origin gh-pages

- run: git worktree remove /tmp/gh-pages

- uses: ./.github/actions/update-index
with:
Expand Down
Loading