diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 35bc2665..33c224dd 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -24,16 +24,13 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # Python setup and testing - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install uv - uses: astral-sh/setup-uv@v4 - with: - version: "latest" + run: pip install uv - name: Install Python dependencies run: uv sync @@ -44,7 +41,6 @@ jobs: - name: Run Python tests run: uv run pytest app/tests/ -v --tb=short - # Frontend setup and testing - name: Install pnpm uses: pnpm/action-setup@v4 with: @@ -85,10 +81,6 @@ jobs: working-directory: ui run: pnpm run generate - # Quick Docker build validation (no push, cache only) - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Validate Docker build uses: docker/build-push-action@v5 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cf472c6c..c9221622 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,7 @@ on: - ".github/ISSUE_TEMPLATE/**" env: + REGISTRY: ${{ vars.REGISTRY != '' && vars.REGISTRY || '' }} DOCKERHUB_SLUG: arabcoders/ytptube GHCR_SLUG: ghcr.io/arabcoders/ytptube PNPM_VERSION: 10 @@ -40,18 +41,13 @@ jobs: with: fetch-depth: 0 - # Python setup and testing - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install uv - uses: astral-sh/setup-uv@v6.7 - with: - enable-cache: true - save-cache: true - version: "latest" + run: pip install uv - name: Install Python dependencies run: uv sync @@ -62,7 +58,6 @@ jobs: - name: Run Python tests run: uv run pytest app/tests/ -v --tb=short - # Frontend setup and testing - name: Install pnpm uses: pnpm/action-setup@v4 with: @@ -138,6 +133,7 @@ jobs: packages: write contents: write env: + SLUG: ${{ format('{0}/{1}', env.REGISTRY, github.repository) }} ARCH: ${{ matrix.arch }} steps: - name: Checkout @@ -178,8 +174,9 @@ jobs: uses: docker/metadata-action@v5 with: images: | - ${{ env.DOCKERHUB_SLUG }} - ${{ env.GHCR_SLUG }} + name=${{ env.DOCKERHUB_SLUG }},enable=${{ env.REGISTRY == '' }} + name=${{ env.GHCR_SLUG }},enable=${{ env.REGISTRY == '' }} + name=${{ env.REGISTRY }}/${{ github.repository }},enable=${{ env.REGISTRY != '' }} flavor: | latest=false suffix=-${{ env.ARCH }} @@ -188,8 +185,17 @@ jobs: type=ref,event=tag type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + - name: Login to Private Registry + uses: docker/login-action@v3 + if: env.REGISTRY != '' + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GIT_TOKEN && secrets.GIT_TOKEN || secrets.GITHUB_TOKEN }} + - name: Login to GitHub Container Registry uses: docker/login-action@v3 + if: env.REGISTRY == '' with: registry: ghcr.io username: ${{ github.actor }} @@ -197,6 +203,7 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v3 + if: env.REGISTRY == '' with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -212,13 +219,9 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: | - type=gha,scope=${{ github.workflow }} - type=registry,ref=ghcr.io/arabcoders/ytptube:buildcache - cache-to: | - type=gha,mode=max,scope=${{ github.workflow }} - type=registry,ref=ghcr.io/arabcoders/ytptube:buildcache,mode=max - provenance: false + cache-to: type=gha,mode=max,scope=${{ github.workflow }} + cache-from: type=gha,scope=${{ github.workflow }} + provenance: true docker-publish-manifest: name: Publish multi-arch manifest @@ -233,8 +236,9 @@ jobs: uses: docker/metadata-action@v5 with: images: | - ${{ env.DOCKERHUB_SLUG }} - ${{ env.GHCR_SLUG }} + name=${{ env.DOCKERHUB_SLUG }},enable=${{ env.REGISTRY == '' }} + name=${{ env.GHCR_SLUG }},enable=${{ env.REGISTRY == '' }} + name=${{ env.REGISTRY }}/${{ github.repository }},enable=${{ env.REGISTRY != '' }} flavor: | latest=false tags: | @@ -242,8 +246,17 @@ jobs: type=ref,event=tag type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + - name: Login to Private Registry + uses: docker/login-action@v3 + if: env.REGISTRY != '' + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GIT_TOKEN && secrets.GIT_TOKEN || secrets.GITHUB_TOKEN }} + - name: Login to GitHub Container Registry uses: docker/login-action@v3 + if: env.REGISTRY == '' with: registry: ghcr.io username: ${{ github.actor }} @@ -251,6 +264,7 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v3 + if: env.REGISTRY == '' with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -268,7 +282,7 @@ jobs: done - name: Overwrite GitHub release notes - if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(github.ref, 'refs/tags/v') && env.REGISTRY == '' uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -322,6 +336,7 @@ jobs: steps: - name: Sync README uses: docker://lsiodev/readme-sync:latest + if: env.REGISTRY == '' env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index d630119b..e7723e65 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -14,8 +14,12 @@ on: tags: - "v*" +env: + REGISTRY: ${{ vars.REGISTRY != '' && vars.REGISTRY || '' }} + jobs: build: + if: env.REGISTRY == '' runs-on: ${{ matrix.os }} strategy: matrix: