Pre-render README.md into index.html for SEO (static content for craw… #25
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
| # ────────────────────────────────────────────── | |
| # IndexNow 自動提交 workflow | |
| # 觸發條件: | |
| # 1. 每次 push 到 main(任何更動皆通知搜尋引擎) | |
| # 2. 每週一早上 9:00(台灣時間)定期提交 | |
| # 3. 手動觸發(workflow_dispatch) | |
| # ────────────────────────────────────────────── | |
| name: IndexNow Submit | |
| on: | |
| push: | |
| branches: [main] | |
| schedule: | |
| # 每週一 01:00 UTC = 台灣時間 09:00 | |
| - cron: '0 1 * * 1' | |
| workflow_dispatch: | |
| jobs: | |
| submit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Submit URLs to IndexNow | |
| run: | | |
| HOST="canslab1.github.io" | |
| KEY="d22a81b36ccb45e085fe6679a822df52" | |
| REPO="HATA" | |
| URLS=( | |
| "https://${HOST}/${REPO}/" | |
| "https://${HOST}/${REPO}/index.html" | |
| "https://${HOST}/${REPO}/sitemap.xml" | |
| "https://${HOST}/${REPO}/llms.txt" | |
| "https://${HOST}/${REPO}/robots.txt" | |
| ) | |
| # 組合 JSON 陣列 | |
| URL_JSON="[" | |
| for i in "${!URLS[@]}"; do | |
| [ $i -gt 0 ] && URL_JSON+="," | |
| URL_JSON+="\"${URLS[$i]}\"" | |
| done | |
| URL_JSON+="]" | |
| echo "══════════════════════════════════════" | |
| echo " IndexNow 自動提交 — ${REPO}" | |
| echo " 提交頁數: ${#URLS[@]}" | |
| echo "══════════════════════════════════════" | |
| RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ | |
| "https://api.indexnow.org/IndexNow" \ | |
| -H "Content-Type: application/json; charset=utf-8" \ | |
| -d "{ | |
| \"host\": \"${HOST}\", | |
| \"key\": \"${KEY}\", | |
| \"keyLocation\": \"https://${HOST}/${KEY}.txt\", | |
| \"urlList\": ${URL_JSON} | |
| }") | |
| echo "" | |
| for url in "${URLS[@]}"; do | |
| echo " ✓ ${url}" | |
| done | |
| echo "" | |
| if [ "$RESPONSE" = "200" ] || [ "$RESPONSE" = "202" ]; then | |
| echo "✅ 提交成功 (HTTP ${RESPONSE})" | |
| else | |
| echo "⚠️ 回應碼: HTTP ${RESPONSE}" | |
| exit 1 | |
| fi |