Skip to content

Commit

Permalink
Add GitHub action to create index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
korenmiklos authored Jan 18, 2024
1 parent ea95d0b commit e3704f8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Update Index HTML for All Folders

on:
push:

jobs:
update-index:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Generate Index HTML for Each Folder
run: |
find . -type d -not -path '*/\.*' | while read -r dir; do
if [ "$(ls -A "$dir")" ]; then
echo "<html><body><ul>" > "$dir/index.html"
for file in "$dir"/*; do
[ -e "$file" ] || continue
[ -f "$file" ] || continue
file_name=$(basename "$file")
echo "<li><a href='${file_name}'>${file_name}</a></li>" >> "$dir/index.html"
done
echo "</ul></body></html>" >> "$dir/index.html"
fi
done
- name: Commit and Push
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git add .
git commit -m 'Update index.html files' || exit 0 # Exit gracefully if no changes
git push

0 comments on commit e3704f8

Please sign in to comment.