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

58 lines
1.4 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: Run Playlist Generation
run: |
echo "Running playlist generation..."
cd scripts
python generate_playlist.py
if [ -f playlist.m3u ]; then
mv playlist.m3u ../
fi
if [ -f playlist_update.log ]; then
mv playlist_update.log ../
fi
cd ..
- name: Check Results
run: |
if [ -f playlist.m3u ]; then
CHANNEL_COUNT=$(grep -c "^#EXTINF" playlist.m3u || echo "0")
echo "Generated playlist with $CHANNEL_COUNT channels"
else
echo "No playlist generated"
fi
- name: Commit Changes
run: |
git add .
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"
git push
fi