From c512b93c6142a67c92a45384381d6b5f2ba9b82f Mon Sep 17 00:00:00 2001 From: Vladimir Eremin Date: Thu, 5 Nov 2026 23:02:12 +0300 Subject: [PATCH] ci: migrate workflows and dependencies to Gitea Actions --- .dockerignore | 4 ++ .gitea/scripts/docker.py | 64 +++++++++++++++++++++++++++ .gitea/workflows/ci.yml | 95 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 92 -------------------------------------- Dockerfile | 5 ++- 5 files changed, 166 insertions(+), 94 deletions(-) create mode 100644 .gitea/scripts/docker.py create mode 100644 .gitea/workflows/ci.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.dockerignore b/.dockerignore index 798b41f..ef8ae13 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,3 +17,7 @@ !build.sh !config.tsconfig.json !tsconfig.json + +!.ci/ +!.ci/vendor/ +!.ci/vendor/yt-dlp diff --git a/.gitea/scripts/docker.py b/.gitea/scripts/docker.py new file mode 100644 index 0000000..a4f310c --- /dev/null +++ b/.gitea/scripts/docker.py @@ -0,0 +1,64 @@ +import json +import os +import re +import subprocess +import sys +from pathlib import Path + + +def lines(value): + return [line.strip() for line in value.splitlines() if line.strip()] + + +def output(name, value): + with open(os.environ['GITHUB_OUTPUT'], 'a') as stream: + stream.write(f'{name}<> "$GITHUB_PATH" + env: + PNPM_VERSION: ${{ matrix.pnpm-version }} + - name: Use Node.js ${{ matrix.node-version }} + run: | + case "$NODE_VERSION" in + 18*) major=18;; 20*) major=20;; 22*) major=22;; *) exit 1;; + esac + test -x "/opt/ci/node/$major/bin/node" + echo "/opt/ci/node/$major/bin" >> "$GITHUB_PATH" + env: + NODE_VERSION: ${{ matrix.node-version }} + - name: Install dependencies + run: pnpm install + - name: ESLint & Prettier + run: pnpm run lint + - name: Build + run: pnpm run build + - name: Test + run: pnpm run --if-present test + env: + npm_config_build_from_source: 'true' + docker: + runs-on: apex-debian13 + needs: mocha + permissions: + contents: read + packages: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Stage verified yt-dlp asset + run: | + mkdir -p .ci/vendor + cp /opt/ci/assets/yt-dlp .ci/vendor/yt-dlp + - name: Set up QEMU + run: test -r /proc/sys/fs/binfmt_misc/qemu-aarch64 + - name: Set up Docker Buildx + run: | + docker buildx version + docker buildx create --name apex-ci --driver docker-container --use + docker buildx inspect --bootstrap + - name: Log in to Gitea Container Registry + run: python3 .gitea/scripts/docker.py login + env: + REGISTRY: git.ermnvldmr.com + REGISTRY_USER: ${{ github.repository_owner }} + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} + - name: Docker Generate Meta + id: meta + run: python3 .gitea/scripts/docker.py metadata + env: + IMAGES: git.ermnvldmr.com/deytenit/quetza + TAG_RULES: | + type=raw,value=latest,enable=${{ github.ref_type == 'tag' && !contains(github.ref_name, '-') }} + type=raw,value=latest-dev,enable=${{ github.ref_type == 'branch' && github.ref_name == 'master' }} + type=raw,value=${{ github.ref_name }} + type=raw,value=${{ github.sha }},enable=${{ github.ref_type == 'branch' }} + SOURCE_SHA: ${{ github.sha }} + - name: Build and Push Docker Image + run: python3 .gitea/scripts/docker.py build + env: + TAGS: ${{ steps.meta.outputs.tags }} + LABELS: ${{ steps.meta.outputs.labels }} + BUILD_ARGS: '' + DOCKERFILE: '' + PLATFORMS: linux/amd64,linux/arm64 + PUSH: 'true' + CONTEXT: . + SOURCE_SHA: ${{ github.sha }} + RUN_ID: ${{ github.run_id }} + env: + npm_config_build_from_source: 'true' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 09544ad..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Continuous Integration - -on: - push: - tags: - - "*" - branches: - - master - -jobs: - mocha: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [22.x] - pnpm-version: [9] - - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - uses: pnpm/action-setup@v2 - with: - version: ${{ matrix.pnpm-version }} - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - name: Install dependencies - run: pnpm install - - - name: ESLint & Prettier - run: pnpm run lint - - - name: Build - run: pnpm run build - - - name: Test - run: pnpm run --if-present test - - docker: - runs-on: ubuntu-latest - needs: mocha - permissions: - contents: read - packages: write - - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to GitHub Container Registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker Generate Meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/deytenit/quetza - # generate Docker tags based on the following events/attributes - # on tag event: tag using git tag, and as latest if the tag doesn't contain hyphens (pre-releases) - # on push event: tag using git sha, branch name and as latest-dev - tags: | - type=raw,value=latest,enable=${{ github.ref_type == 'tag' && !contains(github.ref_name, '-') }} - type=raw,value=latest-dev,enable=${{ github.ref_type == 'branch' && github.ref_name == 'master' }} - type=raw,value=${{ github.ref_name }} - type=raw,value=${{ github.sha }},enable=${{ github.ref_type == 'branch' }} - flavor: | - latest=false - - - name: Build and Push Docker Image - uses: docker/build-push-action@v5 - with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index da09d60..d2dbe9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ RUN apk add --no-cache make RUN apk add --no-cache gcc RUN apk add --no-cache build-base -RUN npm install -g pnpm +RUN npm install -g pnpm@9.12.3 +ENV npm_config_build_from_source=true WORKDIR /usr/src/app @@ -19,7 +20,7 @@ COPY . . RUN pnpm run build RUN mkdir ./dist/bin/ -RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/src/app/dist/bin/yt-dlp +COPY .ci/vendor/yt-dlp /usr/src/app/dist/bin/yt-dlp RUN chmod a+rx /usr/src/app/dist/bin/yt-dlp RUN pnpm install --prod