Skip to content

Add files via upload #5

Add files via upload

Add files via upload #5

Workflow file for this run

name: Update Index HTML with Subfolders
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><h2>Index of ${dir#./}</h2><ul>" > "$dir/index.html"
for file in "$dir"/*; do
[ -e "$file" ] || continue
file_name=$(basename "$file")
if [ -d "$file" ]; then
# For directories, link to their index.html
echo "<li><a href='${file_name}/index.html'>${file_name}/</a></li>" >> "$dir/index.html"
else
# For files, link directly
echo "<li><a href='${file_name}'>${file_name}</a></li>" >> "$dir/index.html"
fi
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 with subfolder links' || exit 0 # Exit gracefully if no changes
git push