Skip to content

autoupdate-yt-dlp

autoupdate-yt-dlp #626

name: autoupdate-yt-dlp
permissions:
contents: write
on:
workflow_dispatch:
schedule:
- cron: '00 23 * * *'
jobs:
autoupdate-yt-dlp:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pipenv
run: |
python -m pip install --upgrade pip
pip install pipenv
- name: Install yt-dlp and get version
id: check_version
run: |
pipenv install yt-dlp
latest_version=$(pipenv run pip show yt-dlp | grep Version | cut -d' ' -f2)
current_version=$(grep -oP "(?<=yt_dlp\[default\]==)\d+(\.\d+)+" requirements.txt || echo "0.0.0")
echo "LATEST_VERSION=$latest_version" >> $GITHUB_ENV
echo "CURRENT_VERSION=$current_version" >> $GITHUB_ENV
- name: Compare versions and update requirements.txt if necessary
if: ${{ env.LATEST_VERSION != env.CURRENT_VERSION }}
run: |
latest_version=${{ env.LATEST_VERSION }}
sed -i "s/^yt_dlp\[default\].*/yt_dlp\[default\]==$latest_version/" requirements.txt
git config --global user.email "yt-dlp@autoupdate"
git config --global user.name "yt-dlp-autoupdate"
git add requirements.txt
git commit -m "Update yt-dlp version to $latest_version"
git push