diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index 5e250ee..dbc0d74 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -1,10 +1,8 @@ -name: weekly, if new yt-dlp, build + push container to docker/gitea +name: push new builds to gitea, dockerhub on: push: branches: ["master"] - schedule: - - cron: '0 0 * * 0' # weekly workflow_dispatch: jobs: @@ -22,28 +20,7 @@ jobs: exit 1 fi echo "youdis-version=$YOUDIS_VER" >> $GITHUB_OUTPUT - echo "shortsha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT - - - name: Get latest yt-dlp version - id: ytdlp - run: | - LATEST=$(curl -s https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest | jq -r .tag_name) - if [ -z "$LATEST" ]; then - echo "failed to fetch yt-dlp release" >&2 - exit 1 - fi - echo "ytdlp-version=$LATEST" >> $GITHUB_OUTPUT - - - name: Get current yt-dlp version from latest container - id: current_ytdlp - run: | - docker pull eulaly/youdis:latest || true - if docker image inspect eulaly/youdis:latest >/dev/null 2>&1; then - CURR=$(docker inspect --format='{{ index .Config.Labels "YTDLP_VERSION" }}' eulaly/youdis:latest) - else - CURR="none" - fi - echo "current-ytdlp=$CURR" >> $GITHUB_OUTPUT + echo "shortsha=${GITHUB_SHA::5}" >> $GITHUB_OUTPUT - name: Decide if build needed id: check_build @@ -51,8 +28,6 @@ jobs: SHOULD_BUILD=false if [ "${{ steps.youdis.outputs.youdis-version }}" != "$(docker inspect --format='{{ index .Config.Labels "YOUDIS_VERSION" }}' eulaly/youdis:latest || echo none)" ]; then SHOULD_BUILD=true - elif [ "${{ steps.ytdlp.outputs.ytdlp-version }}" != "${{ steps.current_ytdlp.outputs.current-ytdlp }}" ]; then - SHOULD_BUILD=true fi echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT @@ -69,17 +44,15 @@ jobs: push: true tags: | eulaly/youdis:latest - eulaly/youdis:ytldlp-${{ steps.ytdlp.outputs.ytdlp-version }}.youdis-${{ steps.youdis.outputs.shortsha }} + eulaly/youdis:${{ steps.youdis.outputs.shortsha }} labels: | YOUDIS_VERSION=${{ steps.youdis.outputs.youdis-version }} - YTDLP_VERSION=${{ steps.ytdlp.outputs.ytdlp-version }} - name: Login to Gitea uses: docker/login-action@v3 with: registry: git.hgsky.me username: ${{ secrets.USERNAME }} - #username: ${{ vars.CI_ACTOR }} password: ${{ secrets.YOUDIS_PASSWORD }} - name: Build and push to Gitea @@ -89,10 +62,9 @@ jobs: push: true tags: | git.hgsky.me/ben/youdis:latest - git.hgsky.me/ben/youdis:ytldlp-${{ steps.ytdlp.outputs.ytdlp-version }}.youdis-${{ steps.youdis.outputs.shortsha }} + git.hgsky.me/ben/youdis:${{ steps.youdis.outputs.shortsha }} labels: | YOUDIS_VERSION=${{ steps.youdis.outputs.youdis-version }} - YTDLP_VERSION=${{ steps.ytdlp.outputs.ytdlp-version }} - name: link container in gitea run: | diff --git a/create-ytdlp-config.sh b/create-ytdlp-config.sh deleted file mode 100644 index 7bc59ef..0000000 --- a/create-ytdlp-config.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -#copy yt-dlp.conf if missing -mkdir -p /config -if [ ! -f /config/yt-dlp.conf ]; then - cp /app/default-yt-dlp.conf /config/yt-dlp.conf -fi - -exec "$@" diff --git a/dockerfile b/dockerfile index 8cd94e5..9bc30e7 100644 --- a/dockerfile +++ b/dockerfile @@ -4,11 +4,13 @@ WORKDIR /app RUN apk update && \ apk add --no-cache build-base ffmpeg && \ rm -rf /var/cache/apk/* -COPY requirements.txt requirements.txt +COPY requirements.txt . RUN python3 -m pip install --no-cache-dir -r requirements.txt -COPY youdis.py youdis.py -COPY default-yt-dlp.conf /app/default-yt-dlp.conf -COPY create-ytdlp-config.sh /app/create-ytdlp-config.sh -RUN chmod 755 /app/create-ytdlp-config.sh -ENTRYPOINT ["/app/create-ytdlp-config.sh"] -CMD ["python3", "youdis.py"] \ No newline at end of file + +COPY youdis.py, default-yt-dlp.conf, update-ytdlp.sh run-youdis.sh /app/ +RUN chmod +x /app/update-ytdlp.sh /app/run-youdis.sh + +COPY weekly-restart /etc/cron.d/ +RUN chmod 0644 /etc/cron.d/weekly-restart + +ENTRYPOINT ["/app/run-youdis.sh"] diff --git a/run-youdis.sh b/run-youdis.sh new file mode 100644 index 0000000..ccaa2e3 --- /dev/null +++ b/run-youdis.sh @@ -0,0 +1,21 @@ + #!/bin/sh +set -e + +#start crond in bg +crond -l 2 + +echo "checking for /config/yt-dlp.conf" +#copy yt-dlp.conf if missing +mkdir -p /config +if [ ! -f /config/yt-dlp.conf ]; then + echo "yt-dlp.conf not found, setting default" + cp /app/default-yt-dlp.conf /config/yt-dlp.conf + echo "created yt-dlp.conf" +fi + +python3 -m pip install --no-cache-dir --upgrade --pre "yt-dlp[default]" +VERSION=$(python3 -m pip show yt-dlp 2>/dev/null | awk '/Version:/ {print $2}') +echo "updated yt-dlp to $VERSION" + +echo "starting youdis" +exec python3 /app/youdis.py diff --git a/update-ytdlp.sh b/update-ytdlp.sh new file mode 100644 index 0000000..24e1c62 --- /dev/null +++ b/update-ytdlp.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +echo "updating yt-dlp" +echo "killing youdis" +pkill -f youdis.py || true +python3 -m pip install --no-cache-dir --upgrade --pre "yt-dlp[default]" +VERSION=$(python3 -m pip show yt-dlp 2>/dev/null | awk '/Version:/ {print $2}') + +echo "updated yt-dlp to $VERSION" +echo "restarting youdis" +python3 /app/youdis.py & diff --git a/weekly-restart b/weekly-restart new file mode 100644 index 0000000..49c089b --- /dev/null +++ b/weekly-restart @@ -0,0 +1 @@ +0 3 * * 0 root /app/update-ytdlp.sh diff --git a/youdis-version.txt b/youdis-version.txt index cee245b..291c506 100644 --- a/youdis-version.txt +++ b/youdis-version.txt @@ -1 +1 @@ -20250824-f173c64 +20250829-d539915