Update .forgejo/workflows/generate-m3u.yml
Some checks failed
📺 Generate M3U Playlist / build (push) Has been cancelled

This commit is contained in:
stoney420 2025-06-27 17:36:55 +02:00
parent efba1c1333
commit e7deeed53c

View file

@ -1,4 +1,4 @@
name: Generate M3U Playlist
name: 📺 Generate M3U Playlist
on:
push:
@ -10,73 +10,163 @@ jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
- name: 📥 Checkout Repository
uses: actions/checkout@v4
- name: Set up Python
- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'
- name: Configure Git
- name: ⚙️ Configure Git
run: |
git config --local user.email "actions@forgejo.plainrock127.xyz"
git config --local user.name "Gitea Actions Bot"
git config --local user.name "IPTV Playlist Bot"
- name: Set file permissions and debug
- name: 📁 Create directory structure
run: |
echo "=== Current user and permissions ==="
whoami
pwd
ls -la
echo "=== Setting file permissions ==="
chmod 664 channels.txt || echo "Could not chmod channels.txt"
chmod 664 bulk_import.m3u || echo "Could not chmod bulk_import.m3u (might not exist)"
chmod 775 . || echo "Could not chmod directory"
echo "=== Files before processing ==="
echo "channels.txt line count:"
wc -l channels.txt || echo "channels.txt not found"
echo "bulk_import.m3u exists:"
ls -la bulk_import.m3u || echo "bulk_import.m3u not found"
- name: Generate M3U
run: python generate_playlist.py
echo "=== Creating directory structure ==="
mkdir -p logs config templates scripts docs
chmod 664 channels.txt 2>/dev/null || echo "channels.txt not found"
chmod 664 bulk_import.m3u 2>/dev/null || echo "bulk_import.m3u not found"
- name: Debug after processing
- name: 🔍 Pre-processing diagnostics
run: |
echo "=== Files after processing ==="
echo "=== Repository Status ==="
pwd && whoami && ls -la
echo "=== File Status ==="
if [ -f channels.txt ]; then
echo "channels.txt: $(wc -l < channels.txt) lines"
else
echo "channels.txt: Not found"
fi
if [ -f bulk_import.m3u ]; then
echo "bulk_import.m3u: $(wc -l < bulk_import.m3u) lines"
else
echo "bulk_import.m3u: Not found"
fi
- name: 🚀 Generate M3U Playlist
run: |
echo "Starting playlist generation..."
python scripts/generate_playlist.py
- name: 📊 Post-processing diagnostics
run: |
echo "=== Processing Results ==="
ls -la
echo "=== channels.txt line count after ==="
wc -l channels.txt || echo "channels.txt not found"
echo "=== bulk_import.m3u still exists? ==="
ls -la bulk_import.m3u || echo "bulk_import.m3u not found (good!)"
echo "=== Log content ==="
cat playlist_update.log || echo "No log file"
echo "=== playlist.m3u line count ==="
wc -l playlist.m3u || echo "playlist.m3u not found"
- name: Prepare for Pages
if [ -f playlist.m3u ]; then
echo "playlist.m3u: Generated ($(wc -l < playlist.m3u) lines)"
else
echo "playlist.m3u: Not generated"
fi
if [ -f bulk_import.m3u ]; then
echo "bulk_import.m3u: Still exists"
else
echo "bulk_import.m3u: Cleaned up"
fi
echo "=== Logs ==="
if [ -f logs/playlist_update.log ]; then
echo "Main log (last 10 lines):"
tail -10 logs/playlist_update.log
fi
if [ -f logs/error.log ]; then
echo "Errors found:"
cat logs/error.log
else
echo "No errors logged"
fi
- name: 📊 Generate statistics
run: |
if [ -f playlist.m3u ]; then
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
GROUPS=$(grep -o 'group-title="[^"]*"' playlist.m3u | sort -u | wc -l || echo "0")
echo "Total channels: $CHANNEL_COUNT"
echo "Number of groups: $GROUPS"
else
echo "No playlist generated"
fi
- name: 📦 Prepare deployment
run: |
mkdir -p docs
cp playlist.m3u docs/playlist.m3u
cp playlist_update.log docs/playlist_update.log || true
- name: Commit and Push
run: |
git add channels.txt || echo "No channels.txt to add"
git add playlist.m3u || echo "No playlist.m3u to add"
git add playlist_update.log || echo "No playlist_update.log to add"
git add docs/playlist.m3u || echo "No docs/playlist.m3u to add"
git add docs/playlist_update.log || echo "No docs/playlist_update.log to add"
[ -f playlist.m3u ] && cp playlist.m3u docs/
[ -f channels.txt ] && cp channels.txt docs/
[ -d logs ] && cp -r logs docs/
cat > docs/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<title>📺 IPTV Playlist</title>
<meta charset="UTF-8">
<style>
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; }
.container { max-width: 800px; background: white; padding: 30px; border-radius: 10px; }
h1 { color: #333; border-bottom: 3px solid #007acc; padding-bottom: 10px; }
.download-btn {
display: inline-block; padding: 12px 24px; background: #007acc;
color: white; text-decoration: none; border-radius: 5px; margin: 10px 5px;
}
.download-btn:hover { background: #005a99; }
.file-list a {
display: block; padding: 10px 15px; color: #007acc;
text-decoration: none; border-bottom: 1px solid #eee;
}
</style>
</head>
<body>
<div class="container">
<h1>📺 IPTV Playlist Manager</h1>
<div>
<h3>📊 Quick Access</h3>
<a href="playlist.m3u" class="download-btn" download>📺 Download Playlist</a>
<a href="channels.txt" class="download-btn">📋 View Channels</a>
</div>
<h3>📁 Available Files</h3>
<div class="file-list">
<a href="playlist.m3u">📺 playlist.m3u - Main IPTV playlist</a>
<a href="channels.txt">📋 channels.txt - Channel database</a>
<a href="logs/">📊 logs/ - Processing logs</a>
</div>
<p><strong>Last Updated:</strong> <span id="timestamp"></span></p>
<script>
document.getElementById('timestamp').textContent = new Date().toLocaleString();
</script>
</div>
</body>
</html>
EOF
- name: 💾 Commit and push changes
run: |
rm -f *.backup* || true
[ -f channels.txt ] && git add channels.txt
[ -f playlist.m3u ] && git add playlist.m3u
[ -d logs ] && git add logs/
[ -d config ] && git add config/
[ -d docs ] && git add docs/
echo "=== Git status ==="
git status
if git diff --staged --quiet; then
echo "No changes to commit"
exit 0
else
git commit -m "Update M3U playlist via Gitea Actions - $(date)"
CHANNEL_COUNT="0"
if [ -f playlist.m3u ]; then
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
fi
COMMIT_MSG="🎬 Updated IPTV playlist: $CHANNEL_COUNT channels ($(date '+%Y-%m-%d %H:%M'))"
git commit -m "$COMMIT_MSG"
git push
echo "Changes committed successfully!"
fi
env:
GITEA_TOKEN
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}