Files
hyprarch-repo/.github/workflows/update-repo.yml
2026-03-11 17:57:06 +00:00

67 lines
2.2 KiB
YAML

name: Update Arch Repository
on:
push:
paths:
- 'x86_64/*.pkg.tar.zst'
workflow_dispatch:
jobs:
update-db:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup tools
run: sudo apt-get update && sudo apt-get install -y libarchive-tools
- name: Update Repository Database
run: |
cd x86_64
# Rebuild the DB (Manual tar to ensure compatibility)
tar -cvzf hyprarch-repo.db.tar.gz *.pkg.tar.zst
# Fix symlinks for GitHub Pages
rm -f hyprarch-repo.db hyprarch-repo.files
cp hyprarch-repo.db.tar.gz hyprarch-repo.db
cp hyprarch-repo.files.tar.gz hyprarch-repo.files
- name: Generate Python-style Index
run: |
# 1. Create index for x86_64 folder
cd x86_64
echo "<html><head><title>Index of /x86_64/</title></head><body>" > index.html
echo "<h1>Index of /x86_64/</h1><hr><pre>" >> index.html
echo "<a href='../'>../</a>" >> index.html
for file in *; do
if [ "$file" != "index.html" ]; then
size=$(du -sh "$file" | cut -f1)
date=$(date -r "$file" '+%d-%b-%Y %H:%M')
echo "<a href='$file'>$file</a>$(printf '%*s' $((50 - ${#file})) '') $date $size" >> index.html
fi
done
echo "</pre><hr></body></html>" >> index.html
# 2. Create index for the Root folder
cd ..
echo "<html><head><title>Index of /</title></head><body>" > index.html
echo "<h1>Index of /</h1><hr><pre>" >> index.html
echo "<a href='x86_64/'>x86_64/</a>" >> index.html
echo "</pre><hr></body></html>" >> index.html
- name: Commit and Push changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
if ! git diff-index --quiet HEAD; then
git commit -m "Automated database and index update"
git push
else
echo "Nothing to change."
fi