iptv/.github/workflows/m3u8.yml
2025-09-01 21:57:58 -04:00

96 lines
2.8 KiB
YAML

name: fetch m3u8
on:
schedule:
- cron: "0 * * * *"
workflow_dispatch:
jobs:
m3u8-fetcher:
runs-on: ubuntu-latest
steps:
- name: Check time
id: check_time
run: |
hour=$(TZ=America/New_York date +%-H)
(( hour >= 8 && hour <= 23 )) && echo "run=true" >> $GITHUB_OUTPUT || echo "run=false" >> $GITHUB_OUTPUT
- name: Checkout
if: steps.check_time.outputs.run == 'true'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup SSH Agent
if: steps.check_time.outputs.run == 'true'
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Cache venv
if: steps.check_time.outputs.run == 'true'
uses: actions/cache@v3
with:
path: .venv
key: shared-venv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
shared-venv-${{ runner.os }}-
- name: Install uv
if: steps.check_time.outputs.run == 'true'
uses: astral-sh/setup-uv@v6
with:
version: "latest"
enable-cache: true
ignore-nothing-to-cache: true
cache-dependency-glob: "uv.lock"
- name: Setup Python
if: steps.check_time.outputs.run == 'true'
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Cache Playwright browsers
if: steps.check_time.outputs.run == 'true'
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright
restore-keys: |
${{ runner.os }}-playwright
- name: Install Playwright browsers
if: steps.check_time.outputs.run == 'true'
run: uv run playwright install
- name: Install Playwright deps
if: steps.check_time.outputs.run == 'true'
run: |
set -e
missing_pkgs=()
for pkg in libevent-2.1-7 libavif13; do
if ! dpkg -s $pkg >/dev/null 2>&1; then
missing_pkgs+=($pkg)
fi
done
if (( ${#missing_pkgs[@]} > 0 )); then
apt-get update
apt-get install -y "${missing_pkgs[@]}"
fi
- name: Fetch M3U8
if: steps.check_time.outputs.run == 'true'
run: uv run M3U8/fetch.py
- name: Push changes
if: steps.check_time.outputs.run == 'true'
uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: "update M3U8"
file_pattern: "M3U8/TV.m3u8 M3U8/scrape/tvpass.json"
commit_author: "GitHub Actions Bot <actions@github.com>"
commit_user_name: "GitHub Actions Bot"
commit_user_email: "actions@github.com"