2025-06-29 06:00:33 +02:00
|
|
|
name: Generate M3U Playlist with Auto-Organization
|
2025-06-29 05:30:52 +02:00
|
|
|
|
2025-06-29 05:17:57 +02:00
|
|
|
on:
|
|
|
|
push:
|
2025-06-29 06:00:33 +02:00
|
|
|
branches:
|
|
|
|
- main
|
2025-06-29 05:17:57 +02:00
|
|
|
workflow_dispatch:
|
|
|
|
|
2025-06-29 05:11:17 +02:00
|
|
|
jobs:
|
2025-06-29 06:00:33 +02:00
|
|
|
build-and-organize:
|
|
|
|
runs-on: ubuntu-22.04
|
2025-06-29 05:11:17 +02:00
|
|
|
steps:
|
2025-06-29 06:00:33 +02:00
|
|
|
- name: Checkout Repository
|
2025-06-29 05:11:17 +02:00
|
|
|
uses: actions/checkout@v4
|
2025-06-29 06:00:33 +02:00
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v5
|
2025-06-29 05:45:01 +02:00
|
|
|
with:
|
2025-06-29 06:00:33 +02:00
|
|
|
python-version: '3.11' # Ensure Python 3.11 is available
|
|
|
|
|
|
|
|
- name: Configure Git
|
2025-06-29 05:17:57 +02:00
|
|
|
run: |
|
2025-06-29 06:00:33 +02:00
|
|
|
git config --local user.email "actions@forgejo.plainrock127.xyz"
|
|
|
|
git config --local user.name "IPTV Playlist Bot"
|
|
|
|
|
|
|
|
- name: Basic Setup
|
2025-06-29 05:17:57 +02:00
|
|
|
run: |
|
2025-06-29 06:00:33 +02:00
|
|
|
echo "Basic setup complete."
|
|
|
|
|
|
|
|
- name: Run Playlist Generation
|
2025-06-29 05:57:58 +02:00
|
|
|
run: |
|
2025-06-29 06:00:33 +02:00
|
|
|
echo "Running playlist generation..."
|
|
|
|
python scripts/generate_playlist.py
|
|
|
|
|
|
|
|
- name: Commit and Push if Changes
|
2025-06-29 05:17:57 +02:00
|
|
|
run: |
|
2025-06-29 06:00:33 +02:00
|
|
|
git add .
|
|
|
|
if ! git diff-index --quiet HEAD; then
|
|
|
|
echo "Changes detected, committing..."
|
2025-06-29 05:30:52 +02:00
|
|
|
|
2025-06-29 06:00:33 +02:00
|
|
|
# --- NEW STEPS ---
|
|
|
|
# 1. Commit the changes made by this workflow locally first.
|
|
|
|
# This puts the local repository in a clean state for git pull --rebase.
|
|
|
|
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
|
|
|
git commit -m "📺 Workflow generated files: $CHANNELS channels (temp commit for rebase)"
|
|
|
|
|
|
|
|
# 2. Pull the latest changes from remote and rebase our local commit on top.
|
|
|
|
git pull --rebase origin main
|
|
|
|
|
|
|
|
# --- END NEW STEPS ---
|
|
|
|
|
|
|
|
# Now, push the rebased commit.
|
|
|
|
git push
|
|
|
|
echo "Changes committed successfully"
|
2025-06-29 05:57:58 +02:00
|
|
|
else
|
2025-06-29 06:00:33 +02:00
|
|
|
echo "No changes to commit"
|
2025-06-29 05:11:17 +02:00
|
|
|
fi
|
2025-06-29 06:00:33 +02:00
|
|
|
|
|
|
|
- name: Summary
|
|
|
|
run: |
|
|
|
|
CHANNELS=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
|
|
|
|
echo "=== WORKFLOW COMPLETE ==="
|
|
|
|
echo "✅ Playlist has $CHANNELS channels"
|