fix: typo #24
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: Docs to GitHub Pages | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
# --------------------------------------------------------- # | |
# 1. Pull extra docs from external repo | |
# --------------------------------------------------------- # | |
pull-docs: | |
if: github.actor != 'github-actions[bot]' | |
runs-on: ubuntu-latest | |
permissions: { contents: read } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Make fetch_docs.sh executable | |
run: chmod +x ./src/scripts/fetch_docs.sh | |
- name: Fetch all docs | |
run: ./src/scripts/fetch_docs.sh | |
- name: Upload docs artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs-raw | |
path: ./docs/ | |
# --------------------------------------------------------- # | |
# 2. Commit those docs back into the repo (if changed) | |
# --------------------------------------------------------- # | |
commit-docs: | |
needs: pull-docs | |
if: github.actor != 'github-actions[bot]' | |
runs-on: ubuntu-latest | |
permissions: { contents: write } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Download docs artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: docs-raw | |
path: ./docs/dev/ | |
- name: Commit & push if changed | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add docs/ | |
git commit -m "Update pulled docs" || echo "No changes" | |
# ---- Auth for push ---- | |
git remote set-url origin \ | |
https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
git push origin HEAD:main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# --------------------------------------------------------- # | |
# 3. Build site + Tina, publish to gh-pages | |
# --------------------------------------------------------- # | |
deploy: | |
needs: commit-docs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install deps | |
run: npm ci | |
# ----- Build Tina admin (./admin) ----- | |
- name: Build TinaCMS admin | |
env: | |
TINA_PUBLIC_CLIENT_ID: ${{ secrets.TINA_PUBLIC_CLIENT_ID }} | |
TINA_TOKEN: ${{ secrets.TINA_TOKEN }} | |
run: npx tinacms build | |
# ----- Build Docusaurus site (./build) ----- | |
- name: Build docs site | |
env: | |
DOCS_BASEURL: ${{ secrets.DOCS_BASEURL }} # e.g. /Docusaurus-docs/ | |
run: npm run build | |
# ----- Copy Tina into <baseUrl>/admin ----- | |
- name: Relocate Tina admin inside baseUrl | |
run: | | |
set -euo pipefail | |
BASE="${DOCS_BASEURL#/}" # strip leading / | |
BASE="${BASE%/}" # strip trailing / | |
if [[ -z "$BASE" ]]; then | |
echo "Base URL is '/', nothing to move." | |
exit 0 | |
fi | |
SRC="./admin" | |
DEST="./build/${BASE}/admin" | |
echo "Copying $SRC → $DEST" | |
mkdir -p "$DEST" | |
cp -a "$SRC"/. "$DEST"/ | |
ls -R "$DEST" | head | |
env: | |
DOCS_BASEURL: ${{ secrets.DOCS_BASEURL }} | |
# ----- Publish to gh-pages ----- | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: ./build |