|
20 | 20 | id: file_list |
21 | 21 | run: | |
22 | 22 | echo "Generating file list..." |
| 23 | + python3 << 'PY' |
| 24 | + import json, os |
| 25 | + paths = [] |
| 26 | + for root, dirs, files in os.walk("."): |
| 27 | + if ".git" in root.split(os.sep): |
| 28 | + continue |
| 29 | + for f in files: |
| 30 | + if f.endswith(".php"): |
| 31 | + rel = os.path.relpath(os.path.join(root, f), ".").replace("\\", "/") |
| 32 | + paths.append(rel) |
| 33 | + paths.sort() |
| 34 | + with open("files-manifest.json", "w", encoding="utf-8") as out: |
| 35 | + json.dump({"version": 1, "files": paths}, out, separators=(",", ":")) |
| 36 | + print("files-manifest.json:", len(paths), "PHP files") |
| 37 | + PY |
23 | 38 | # Find all .php files, sort them, and format as Markdown links |
24 | 39 | # Format: - [Filename](URL) |
25 | | - FILES=$(find . -maxdepth 1 -name "*.php" -type f | sort | sed 's|^\./||' | while read -r file; do echo "- [📄 $file](https://github.com/${{ github.repository }}/blob/main/$file)"; done) |
| 40 | + FILES=$(find . -path './.git' -prune -o -name '*.php' -type f -print | sort | sed 's|^\./||' | while read -r file; do echo "- [📄 $file](https://github.com/${{ github.repository }}/blob/main/$file)"; done) |
26 | 41 | |
27 | 42 | # Export to environment variable (multiline safe) |
28 | 43 | echo "FILES<<EOF" >> $GITHUB_ENV |
|
58 | 73 | run: | |
59 | 74 | git config --global user.name "github-actions[bot]" |
60 | 75 | git config --global user.email "github-actions[bot]@users.noreply.github.com" |
61 | | - git add README.md |
| 76 | + git add README.md files-manifest.json |
62 | 77 | # Only commit if there are changes |
63 | | - git diff --quiet && git diff --staged --quiet || (git commit -m "docs: auto-update file list in README" && git push) |
| 78 | + git diff --quiet && git diff --staged --quiet || (git commit -m "docs: sync README and files-manifest for PHP portfolio" && git push) |
0 commit comments