Skip to content

Update main.yml

Update main.yml #13

Workflow file for this run

name: Update README with Latest Files
on:
push:
schedule:
- cron: "0 * * * *" # Runs every hour to update the README
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Last 5 Modified Files
run: |
echo "## 📂 Last 5 Uploaded Files" > latest_files.md
echo "" >> latest_files.md
git log --pretty=format:'%ad %h' --date=short --name-only | awk 'NF' | head -20 | awk '!seen[$0]++' | head -5 | while read -r filedate hash filename; do
if [[ -n "$filename" ]]; then
echo "- [$filename](https://github.com/AKC23/Programming-problems-solutions/blob/master/$filename) (📅 $filedate)" >> latest_files.md
fi
done
- name: Update README
run: |
sed -i '/## 📂 Last 5 Uploaded Files/,$d' README.md
cat latest_files.md >> README.md
- name: Commit Changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add README.md
git commit -m "Updated README with latest files" || exit 0
git push