All checks were successful
📺 Generate M3U Playlist / build (push) Successful in 1m42s
113 lines
No EOL
3.3 KiB
YAML
113 lines
No EOL
3.3 KiB
YAML
name: 📺 Generate M3U Playlist
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- main
|
||
workflow_dispatch:
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-22.04
|
||
steps:
|
||
- name: 📥 Checkout Repository
|
||
uses: actions/checkout@v4
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
- name: 🐍 Set up Python
|
||
uses: actions/setup-python@v5
|
||
with:
|
||
python-version: '3.11'
|
||
|
||
- name: ⚙️ Configure Git
|
||
run: |
|
||
git config --local user.email "actions@forgejo.plainrock127.xyz"
|
||
git config --local user.name "IPTV Playlist Bot"
|
||
|
||
- name: 🔍 Check files before processing
|
||
run: |
|
||
echo "=== Repository Status ==="
|
||
ls -la
|
||
|
||
echo "=== Checking key files ==="
|
||
if [ -f scripts/generate_playlist.py ]; then
|
||
echo "✅ scripts/generate_playlist.py found"
|
||
else
|
||
echo "❌ scripts/generate_playlist.py missing"
|
||
fi
|
||
|
||
if [ -f channels.txt ]; then
|
||
echo "✅ channels.txt found ($(wc -l < channels.txt) lines)"
|
||
else
|
||
echo "ℹ️ channels.txt not found"
|
||
fi
|
||
|
||
if [ -f bulk_import.m3u ]; then
|
||
echo "✅ bulk_import.m3u found ($(wc -l < bulk_import.m3u) lines)"
|
||
else
|
||
echo "ℹ️ bulk_import.m3u not found (normal if no import)"
|
||
fi
|
||
|
||
- name: 🚀 Generate M3U Playlist
|
||
run: |
|
||
echo "=== Running playlist generation ==="
|
||
python scripts/generate_playlist.py
|
||
|
||
- name: 📊 Check results
|
||
run: |
|
||
echo "=== Results ==="
|
||
ls -la
|
||
|
||
if [ -f playlist.m3u ]; then
|
||
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
||
echo "✅ playlist.m3u generated with $CHANNEL_COUNT channels"
|
||
echo "First 5 lines:"
|
||
head -5 playlist.m3u
|
||
else
|
||
echo "❌ playlist.m3u not generated"
|
||
fi
|
||
|
||
if [ -f playlist_update.log ]; then
|
||
echo "=== Log content ==="
|
||
cat playlist_update.log
|
||
else
|
||
echo "❌ No log file found"
|
||
fi
|
||
|
||
- name: 💾 Commit and push changes
|
||
run: |
|
||
echo "=== Preparing to commit ==="
|
||
|
||
# Pull latest changes first to avoid conflicts
|
||
git pull origin main || echo "Pull failed, continuing anyway"
|
||
|
||
# Add files
|
||
git add channels.txt || true
|
||
git add playlist.m3u || true
|
||
git add playlist_update.log || true
|
||
git add config/ || true
|
||
git add docs/ || true
|
||
|
||
# Check if anything to commit
|
||
if git diff --staged --quiet; then
|
||
echo "ℹ️ No changes to commit"
|
||
else
|
||
CHANNEL_COUNT="0"
|
||
if [ -f playlist.m3u ]; then
|
||
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
||
fi
|
||
|
||
echo "📝 Committing changes..."
|
||
git commit -m "📺 Updated playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M'))"
|
||
|
||
# Try to push, with retry if needed
|
||
echo "🚀 Pushing changes..."
|
||
if ! git push origin main; then
|
||
echo "⚠️ Push failed, trying to pull and push again..."
|
||
git pull origin main --rebase || true
|
||
git push origin main || echo "❌ Push failed again - manual intervention may be needed"
|
||
fi
|
||
|
||
echo "✅ Changes committed and pushed"
|
||
fi |