Skip to content

First Commit

First Commit #5

Workflow file for this run

name: Update HTML with Folders
on:
push:
paths:
- '**/*' # Memicu workflow saat ada perubahan di folder manapun
schedule:
- cron: '*/1 * * * *' # Opsional: Menjalankan setiap menit
jobs:
update-html:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get all folders
id: get_folders
run: |
FOLDERS=$(ls -d */ | grep -v '\.github\|node_modules')
echo "folders=${FOLDERS}" >> $GITHUB_ENV
- name: Check for changes and update index.html
run: |
if [ -z "${{ env.folders }}" ]; then
echo "No folders found."
exit 0
fi
# Generate folder list for HTML
FOLDER_LIST=""
for folder in ${{ env.folders }}; do
FOLDER_LIST="$FOLDER_LIST<li><a href=\"$folder\">${folder%/}</a></li>\n"
done
# Replace placeholder in HTML with folder list
sed -i.bak "s|<!-- FOLDER_LIST_PLACEHOLDER -->|${FOLDER_LIST}|" index.html
# Check if index.html has changed
if git diff --quiet; then
echo "No changes to index.html. Skipping commit."
exit 0
fi
# If changes exist, commit and push the update
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
git add index.html
git commit -m "Update index.html with project folders"
git push