Update generate-languages.yaml #1
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: Generate languages.json | ||
on: | ||
push: | ||
paths: | ||
- 'wiki/**.md' # Watching changes in the wiki's subfolder | ||
pull_request: | ||
paths: | ||
- 'wiki/**.md' | ||
jobs: | ||
generate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Debug: List wiki folders and Markdown files | ||
run: | | ||
echo "Checking wiki directories..." | ||
for dir in wiki/*; do | ||
if [ -d "$dir" ]; then | ||
echo "Found directory: $dir" | ||
ls -l "$dir"/*.md 2>/dev/null || echo "No Markdown files in $dir" | ||
fi | ||
done | ||
- name: Generate languages.json for each directory | ||
run: | | ||
for dir in wiki/*; do | ||
if [ -d "$dir" ]; then | ||
json_file="$dir/languages.json" | ||
echo '{ "languages": [' > "$json_file" | ||
ls "$dir"/*.md 2>/dev/null | sed 's#.*/##' | sed 's/\.md//g' | jq -R -s -c 'split("\n")[:-1]' >> "$json_file" | ||
echo ']}' >> "$json_file" | ||
fi | ||
done | ||
- name: Commit changes | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git add wiki/*/languages.json | ||
git diff --quiet && git diff --staged --quiet || (git commit -m "Auto-generate languages.json" && git push) |