my-private-iptv-m3u/.forgejo/workflows/generate-m3u.yml

126 lines
3.6 KiB
YAML
Raw Normal View History

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
- 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: Debug File Structure
run: |
echo "=== Root Directory ==="
ls -la
echo ""
echo "=== Scripts Directory ==="
ls -la scripts/
echo ""
echo "=== Check for Import File ==="
if [ -f bulk_import.m3u ]; then
echo "✅ bulk_import.m3u found in root ($(wc -l < bulk_import.m3u) lines)"
else
echo "❌ bulk_import.m3u not found in root"
fi
- name: Setup Directories
run: |
mkdir -p config
mkdir -p backups
mkdir -p reports/logs
mkdir -p templates
# Create scripts/__init__.py if missing
if [ ! -f scripts/__init__.py ]; then
echo '# Scripts package' > scripts/__init__.py
fi
- name: Run Playlist Generation
run: |
echo "=== Running playlist generation ==="
python scripts/generate_playlist.py
- name: Check Results
run: |
echo "=== Final 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 "File size: $(du -h playlist.m3u | cut -f1)"
else
echo "❌ playlist.m3u not generated"
fi
if [ -f channels.txt ]; then
echo "=== channels.txt status ==="
echo "Size: $(du -h channels.txt | cut -f1)"
echo "Lines: $(wc -l < channels.txt)"
fi
# Check logs
if [ -d reports/logs ]; then
echo "=== Logs directory ==="
ls -la reports/logs/
fi
- name: Commit Changes
run: |
echo "=== Preparing to commit (excluding docs) ==="
# Remove docs folder from tracking if it exists
if [ -d docs ]; then
echo "Removing docs folder from repository"
git rm -rf docs/ || true
fi
# Remove old playlist_update.log from root if it exists
if [ -f playlist_update.log ]; then
echo "Removing old playlist_update.log from root"
git rm playlist_update.log || true
fi
# Add specific files/directories only
git add bulk_import.m3u || true
git add channels.txt || true
git add playlist.m3u || true
git add scripts/ || true
git add config/ || true
git add reports/ || true
git add backups/ || true
git add templates/ || true
git add .forgejo/ || true
git add README.md || true
# Explicitly do NOT add docs folder or old logs
echo "Skipping docs/ folder and old logs"
if ! git diff --staged --quiet; then
CHANNEL_COUNT="0"
if [ -f playlist.m3u ]; then
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
fi
git commit -m "📺 Updated playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M')) - Clean repo"
git push
echo "✅ Repository updated (docs excluded)"
else
echo " No changes to commit"
fi