Repository navigation
docs-updated #64
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: Build Docs | |
| on: | |
| repository_dispatch: | |
| types: [docs-updated] | |
| workflow_dispatch: | |
| # a hand edit to a page or a stylesheet gets its ?v= stamp and sitemap date without a manual | |
| # dispatch. The build's own push uses github.token, and GitHub never starts a workflow from | |
| # that, so this cannot loop. | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'index.html' | |
| - 'template*.html' | |
| - '_nav.html' | |
| - '_footer.html' | |
| - 'assets/**' | |
| - '.github/scripts/build-docs.py' | |
| - '.github/workflows/build-docs.yml' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Fetch latest docs from source repo | |
| run: | | |
| # full history, no file contents until checkout: the contributor count reads git log | |
| git clone --filter=blob:none --branch main \ | |
| https://github.com/ravindu644/Droidspaces-OSS.git /tmp/source | |
| rm -rf docs/content/ | |
| mkdir -p docs/content | |
| cp -r /tmp/source/Documentation/. docs/content/ | |
| - name: Install the build's Markdown renderer and highlighter | |
| run: pip install markdown-it-py mdit-py-plugins pygments | |
| - name: Build HTML | |
| run: python3 .github/scripts/build-docs.py | |
| - name: Clean up source markdown | |
| run: rm -rf docs/content/ | |
| - name: Commit and push | |
| id: push | |
| run: | | |
| SHA="${{ github.event.client_payload.sha }}" | |
| if [ -z "$SHA" ]; then | |
| SHA=$(git -C /tmp/source rev-parse HEAD) | |
| fi | |
| git config user.name "docs-bot" | |
| git config user.email "bot@droidspaces.org" | |
| git remote set-url origin \ | |
| https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "pushed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| git commit -m "docs: update from source@${SHA:0:7}" | |
| git push | |
| echo "pushed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Tell Bing and its partners which URLs changed | |
| # IndexNow: Bing feeds ChatGPT search and Yandex, and none of them crawl a small site | |
| # often. The key is public by design; it must be served at the keyLocation URL. | |
| if: steps.push.outputs.pushed == 'true' | |
| run: | | |
| KEY=$(basename "$(ls ????????????????????????????????.txt)" .txt) | |
| grep -o '<loc>[^<]*</loc>' sitemap.xml | sed 's/<[^>]*>//g' | jq -R . | jq -s \ | |
| --arg host www.droidspaces.org --arg key "$KEY" \ | |
| '{host: $host, key: $key, keyLocation: ("https://" + $host + "/" + $key + ".txt"), urlList: .}' \ | |
| > /tmp/indexnow.json | |
| curl -sS -o /dev/null -w 'IndexNow: HTTP %{http_code}\n' \ | |
| -H 'Content-Type: application/json; charset=utf-8' \ | |
| --data @/tmp/indexnow.json https://api.indexnow.org/indexnow |