-
Notifications
You must be signed in to change notification settings - Fork 2
feat(automation): auto-sync listings from NN-slug/index.html #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0757e8c
docs(seo): sync lectures 02/03 to sitemap/llms.txt/README and fix og:url
watanabe-kohei-jp 7e0ea93
feat(automation): auto-sync listings from NN-slug/index.html
watanabe-kohei-jp d4afe55
Merge branch 'main' into work/auto-listings
watanabe-kohei-jp 25bcc94
chore(listings): regenerate sitemap lastmod after merge
watanabe-kohei-jp db5cedc
fix(automation): harden listing sync per code review
watanabe-kohei-jp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: Listings Sync Bot | ||
|
|
||
| # main への push 後に同期ブロックを再生成し、差分があれば | ||
| # github-actions[bot] が main に直接 commit する。PR 段階のチェック | ||
| # (sync-listings-check.yml) を通過していれば通常は no-op で終わる。 | ||
| # | ||
| # ループ防止: bot 自身の push では走らせない。 | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: listings-sync-main | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| sync: | ||
| if: github.actor != 'github-actions[bot]' | ||
| name: Auto-commit listing sync | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.x' | ||
|
|
||
| - name: Run sync_listings --write | ||
| run: python3 scripts/sync_listings.py --write | ||
|
|
||
| - name: Commit if changed | ||
| run: | | ||
| if [[ -z "$(git status --porcelain)" ]]; then | ||
| echo "No changes — listings already in sync." | ||
| exit 0 | ||
| fi | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git add sitemap.xml llms.txt index.html README.md | ||
| git commit -m "chore(listings): auto-sync $(date +%F)" | ||
| git push |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: Listings Sync Check | ||
|
|
||
| # PR 用の verify-only。NN-slug/index.html の追加・変更があった際に | ||
| # sitemap.xml / llms.txt / index.html / README.md の自動生成ブロックが | ||
| # 同期されていなければ fail させる。 | ||
| # ローカルでの修正コマンド: python3 scripts/sync_listings.py --write | ||
| # | ||
| # 詳細: scripts/README.md | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| check: | ||
| name: Verify auto-generated listing blocks | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.x' | ||
|
|
||
| - name: Run sync_listings --check | ||
| run: python3 scripts/sync_listings.py --check | ||
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # scripts/ | ||
|
|
||
| リポジトリ運用のためのユーティリティスクリプト。 | ||
|
|
||
| --- | ||
|
|
||
| ## `sync_listings.py` — 講義一覧の自動同期 | ||
|
|
||
| `NN-slug/index.html` を真実源(source of truth)として、以下の自動生成ブロックを同期する: | ||
|
|
||
| | ファイル | 同期される場所 | | ||
| |---|---| | ||
| | `sitemap.xml` | `<!-- listings:auto:start --> ... :end -->` — 講義 URL の `<url>` ブロック | | ||
| | `llms.txt` | 同上 — 「## 講義」の箇条書き | | ||
| | `index.html`(ルート) | 同上 — `<ul class="map">` の中身 | | ||
| | `README.md` | `<!-- listings:auto:lectures-table:start -->` 〜 — 章テーブル | | ||
| | `README.md` | `<!-- listings:auto:lectures-urls:start -->` 〜 — 公開 URL 一覧 | | ||
|
|
||
| 各 `NN-slug/index.html` の `<title>` と `<meta name="description">` と `<section>` 数が抽出元。 | ||
|
|
||
| ### 使い方 | ||
|
|
||
| ```bash | ||
| # 変更を書き戻す(ローカル開発で使う) | ||
| python3 scripts/sync_listings.py --write | ||
|
|
||
| # ずれていないか確認(CI 用、exit 1 で fail) | ||
| python3 scripts/sync_listings.py --check | ||
| ``` | ||
|
|
||
| ### 新しい講義を追加する流れ | ||
|
|
||
| 1. `_template/` をコピーして `NN-slug/` を作る | ||
| 2. `<title>` / `<meta name="description">` / スライド本文を書く | ||
| 3. `python3 scripts/sync_listings.py --write` で 4 ファイルを同期 | ||
| 4. `git add -A && git commit && PR` | ||
|
|
||
| PR を上げ忘れても CI の `sync-listings-check.yml` が落とすので発見できる。 | ||
| main にマージ後は念のため `sync-listings-bot.yml` が再生成する二重防衛。 | ||
|
|
||
| ### 依存 | ||
|
|
||
| - Python 3.8+(標準ライブラリのみ。`pip install` 不要) | ||
| - `git`(lastmod の取得に使用) | ||
|
|
||
| ### マーカー設計 | ||
|
|
||
| 各ファイルに HTML/XML コメント形式でマーカーを埋める。マーカー間の本文のみ | ||
| スクリプトが再生成し、マーカー外は触らない。 | ||
|
|
||
| ``` | ||
| <!-- listings:auto:start --> | ||
| ... 自動生成 ... | ||
| <!-- listings:auto:end --> | ||
| ``` | ||
|
|
||
| 同じファイルに 2 か所以上ある場合は名前付きにする: | ||
|
|
||
| ``` | ||
| <!-- listings:auto:<name>:start --> | ||
| ... 自動生成 ... | ||
| <!-- listings:auto:<name>:end --> | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.