my-private-iptv-m3u/.forgejo/workflows/generate-m3u.yml
stoney420 4cc17938a8
All checks were successful
Generate M3U Playlist with Auto-Organization / build-and-organize (push) Successful in 1m49s
Update .forgejo/workflows/generate-m3u.yml
2025-06-28 03:08:40 +02:00

138 lines
No EOL
4.4 KiB
YAML

name: Generate M3U Playlist with Auto-Organization
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-organize:
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: Run Comprehensive Cleanup
run: |
echo "Running comprehensive cleanup..."
if [ -f comprehensive_cleanup.py ]; then
python comprehensive_cleanup.py
echo "Comprehensive cleanup completed"
else
echo "Cleanup already completed"
fi
- name: Basic Repository Maintenance
run: |
echo "Running basic maintenance..."
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -name "*.pyc" -delete 2>/dev/null || true
find . -name "*.tmp" -delete 2>/dev/null || true
find . -name "*~" -delete 2>/dev/null || true
mkdir -p reports/logs reports/daily backups config templates
find . -maxdepth 1 -name "*.log" -exec mv {} reports/logs/ \; 2>/dev/null || true
if [ ! -f scripts/__init__.py ]; then
echo '# IPTV Scripts Package' > scripts/__init__.py
fi
echo "Basic maintenance completed"
- name: Check Import File
run: |
echo "Checking import file..."
if [ -f bulk_import.m3u ]; then
LINES=$(wc -l < bulk_import.m3u)
echo "Found bulk_import.m3u with $LINES lines"
if [ "$LINES" -gt 2 ]; then
echo "Contains channels to process"
fi
else
echo "Creating empty bulk_import.m3u"
echo '#EXTM3U' > bulk_import.m3u
fi
- name: Run Playlist Generation
run: |
echo "Running playlist generation..."
if [ -f scripts/generate_playlist.py ]; then
python scripts/generate_playlist.py
echo "Playlist generation completed"
else
echo "Error: generate_playlist.py not found"
exit 1
fi
- name: Check Results
run: |
echo "Checking results..."
if [ -f playlist.m3u ]; then
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
SIZE=$(du -h playlist.m3u | cut -f1)
echo "Generated playlist: $CHANNELS channels ($SIZE)"
# Create simple report
DATE=$(date +%Y%m%d_%H%M%S)
REPORT="reports/daily/report_$DATE.md"
echo "# Playlist Report - $(date)" > "$REPORT"
echo "- Channels: $CHANNELS" >> "$REPORT"
echo "- Size: $SIZE" >> "$REPORT"
echo "- Generated: $(date)" >> "$REPORT"
echo "Created report: $REPORT"
else
echo "No playlist generated"
fi
- name: Clean Import File
run: |
echo "Cleaning import file..."
if [ -f bulk_import.m3u ]; then
LINES=$(wc -l < bulk_import.m3u)
if [ "$LINES" -gt 2 ]; then
echo '#EXTM3U' > bulk_import.m3u
echo "Cleaned import file for next use"
fi
fi
- name: Final Cleanup
run: |
echo "Final cleanup..."
find . -name "*.pyc" -delete 2>/dev/null || true
find . -name "*~" -delete 2>/dev/null || true
find . -name "*.swp" -delete 2>/dev/null || true
rm -f comprehensive_cleanup.py 2>/dev/null || true
echo "Final cleanup completed"
- name: Commit Changes
run: |
echo "Committing changes..."
git add .
if ! git diff --staged --quiet; then
CHANNELS="0"
if [ -f playlist.m3u ]; then
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
fi
git commit -m "Updated playlist: $CHANNELS channels - $(date '+%Y-%m-%d %H:%M')"
git push
echo "Changes committed successfully"
else
echo "No changes to commit"
fi
- name: Summary
run: |
echo "Workflow completed successfully!"
if [ -f playlist.m3u ]; then
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
echo "Playlist: $CHANNELS channels"
fi
echo "Repository is clean and organized"