Sync wikis and Deploy Docusaurus #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync wikis and Deploy Docusaurus | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
sync-wikis: | |
name: Sync wikis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository with wikis | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Sync wikis | |
run: | | |
git submodule foreach ' | |
echo "Updating wiki: $name" | |
if git fetch origin && git reset --hard origin/master || git reset --hard origin/main; then | |
echo "Successfully updated $name" | |
else | |
echo "Failed to update $name" >&2 | |
exit 1 | |
fi | |
' | |
- name: Commit and push changes | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
if git diff-index --quiet HEAD; then | |
echo "No changes detected" | |
else | |
git add . | |
git commit -m "Sync wikis to latest commits" | |
git push | |
fi | |
build: | |
name: Build Docusaurus | |
runs-on: ubuntu-latest | |
needs: sync-wikis | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: 1.2.0 | |
- name: Install dependencies | |
run: bun install | |
- name: Build site | |
run: bun run build | |
- name: Upload Build Artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: build | |
deploy: | |
name: Deploy to GitHub Pages | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |