Skip to content

Commit b02098e

Browse files
committed
ci: auto-update rank index
1 parent b1d0260 commit b02098e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

.github/workflows/kata-pr-init.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ jobs:
4545
echo "$DESC"
4646
} > "$BASEDIR/README.md"
4747
48+
- name: Update index
49+
env:
50+
JSON: ${{ steps.kata.outputs.json }}
51+
run: |
52+
RANK=$(echo $JSON | jq -r '.rank.name // "beta"' | sed 's/ /-/g')
53+
base_dir="./kata/$RANK"
54+
for d in "$base_dir"/*/; do
55+
[[ -f "$d/README.md" ]] || { echo "WARN: No README.md in $d" >&2; continue; }
56+
title=$(sed -n '1s/^# \[\(.\)\(.*\)\](.*$/\1\2/p' "$d/README.md")
57+
id=$(sed -n '1s/.*\/\([^"]*\)".*$/\1/p' "$d/README.md")
58+
echo "- [$title]($(basename "$d") \"$id\")"
59+
done > "$base_dir/index.md"
60+
4861
- name: Commit changes
4962
id: git
5063
env:

0 commit comments

Comments
 (0)