2222 - " .github/ISSUE_TEMPLATE/**"
2323
2424env :
25+ REGISTRY : ${{ vars.REGISTRY != '' && vars.REGISTRY || '' }}
2526 DOCKERHUB_SLUG : arabcoders/ytptube
2627 GHCR_SLUG : ghcr.io/arabcoders/ytptube
2728 PNPM_VERSION : 10
@@ -40,18 +41,13 @@ jobs:
4041 with :
4142 fetch-depth : 0
4243
43- # Python setup and testing
4444 - name : Set up Python
4545 uses : actions/setup-python@v5
4646 with :
4747 python-version : ${{ env.PYTHON_VERSION }}
4848
4949 - name : Install uv
50- uses : astral-sh/setup-uv@v6.7
51- with :
52- enable-cache : true
53- save-cache : true
54- version : " latest"
50+ run : pip install uv
5551
5652 - name : Install Python dependencies
5753 run : uv sync
6258 - name : Run Python tests
6359 run : uv run pytest app/tests/ -v --tb=short
6460
65- # Frontend setup and testing
6661 - name : Install pnpm
6762 uses : pnpm/action-setup@v4
6863 with :
@@ -118,6 +113,7 @@ jobs:
118113
119114 - name : Upload frontend build
120115 uses : actions/upload-artifact@v4
116+ if : env.REGISTRY == ''
121117 with :
122118 name : frontend-build
123119 path : ui/exported/
@@ -147,6 +143,7 @@ jobs:
147143
148144 - name : Download frontend build
149145 uses : actions/download-artifact@v4
146+ if : env.REGISTRY == ''
150147 with :
151148 name : frontend-build
152149 path : ui/exported/
@@ -178,8 +175,9 @@ jobs:
178175 uses : docker/metadata-action@v5
179176 with :
180177 images : |
181- ${{ env.DOCKERHUB_SLUG }}
182- ${{ env.GHCR_SLUG }}
178+ name=${{ env.DOCKERHUB_SLUG }},enable=${{ env.REGISTRY == '' }}
179+ name=${{ env.GHCR_SLUG }},enable=${{ env.REGISTRY == '' }}
180+ name=${{ env.REGISTRY }}/${{ github.repository }},enable=${{ env.REGISTRY != '' }}
183181 flavor : |
184182 latest=false
185183 suffix=-${{ env.ARCH }}
@@ -188,15 +186,25 @@ jobs:
188186 type=ref,event=tag
189187 type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
190188
189+ - name : Login to Private Registry
190+ uses : docker/login-action@v3
191+ if : env.REGISTRY != ''
192+ with :
193+ registry : ${{ env.REGISTRY }}
194+ username : ${{ github.actor }}
195+ password : ${{ secrets.GIT_TOKEN && secrets.GIT_TOKEN || secrets.GITHUB_TOKEN }}
196+
191197 - name : Login to GitHub Container Registry
192198 uses : docker/login-action@v3
199+ if : env.REGISTRY == ''
193200 with :
194201 registry : ghcr.io
195202 username : ${{ github.actor }}
196203 password : ${{ secrets.GITHUB_TOKEN }}
197204
198205 - name : Login to DockerHub
199206 uses : docker/login-action@v3
207+ if : env.REGISTRY == ''
200208 with :
201209 username : ${{ secrets.DOCKERHUB_USERNAME }}
202210 password : ${{ secrets.DOCKERHUB_TOKEN }}
@@ -212,13 +220,9 @@ jobs:
212220 push : true
213221 tags : ${{ steps.meta.outputs.tags }}
214222 labels : ${{ steps.meta.outputs.labels }}
215- cache-from : |
216- type=gha,scope=${{ github.workflow }}
217- type=registry,ref=ghcr.io/arabcoders/ytptube:buildcache
218- cache-to : |
219- type=gha,mode=max,scope=${{ github.workflow }}
220- type=registry,ref=ghcr.io/arabcoders/ytptube:buildcache,mode=max
221- provenance : false
223+ cache-to : type=gha,mode=max,scope=${{ github.workflow }}
224+ cache-from : type=gha,scope=${{ github.workflow }}
225+ provenance : true
222226
223227 docker-publish-manifest :
224228 name : Publish multi-arch manifest
@@ -233,24 +237,35 @@ jobs:
233237 uses : docker/metadata-action@v5
234238 with :
235239 images : |
236- ${{ env.DOCKERHUB_SLUG }}
237- ${{ env.GHCR_SLUG }}
240+ name=${{ env.DOCKERHUB_SLUG }},enable=${{ env.REGISTRY == '' }}
241+ name=${{ env.GHCR_SLUG }},enable=${{ env.REGISTRY == '' }}
242+ name=${{ env.REGISTRY }}/${{ github.repository }},enable=${{ env.REGISTRY != '' }}
238243 flavor : |
239244 latest=false
240245 tags : |
241246 type=ref,event=branch
242247 type=ref,event=tag
243248 type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
244249
250+ - name : Login to Private Registry
251+ uses : docker/login-action@v3
252+ if : env.REGISTRY != ''
253+ with :
254+ registry : ${{ env.REGISTRY }}
255+ username : ${{ github.actor }}
256+ password : ${{ secrets.GIT_TOKEN && secrets.GIT_TOKEN || secrets.GITHUB_TOKEN }}
257+
245258 - name : Login to GitHub Container Registry
246259 uses : docker/login-action@v3
260+ if : env.REGISTRY == ''
247261 with :
248262 registry : ghcr.io
249263 username : ${{ github.actor }}
250264 password : ${{ secrets.GITHUB_TOKEN }}
251265
252266 - name : Login to DockerHub
253267 uses : docker/login-action@v3
268+ if : env.REGISTRY == ''
254269 with :
255270 username : ${{ secrets.DOCKERHUB_USERNAME }}
256271 password : ${{ secrets.DOCKERHUB_TOKEN }}
@@ -268,7 +283,7 @@ jobs:
268283 done
269284
270285 - name : Overwrite GitHub release notes
271- if : startsWith(github.ref, 'refs/tags/v')
286+ if : startsWith(github.ref, 'refs/tags/v') && env.REGISTRY == ''
272287 uses : actions/github-script@v6
273288 with :
274289 github-token : ${{ secrets.GITHUB_TOKEN }}
@@ -322,6 +337,7 @@ jobs:
322337 steps :
323338 - name : Sync README
324339 uses : docker://lsiodev/readme-sync:latest
340+ if : env.REGISTRY == ''
325341 env :
326342 DOCKERHUB_USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
327343 DOCKERHUB_PASSWORD : ${{ secrets.DOCKERHUB_TOKEN }}
0 commit comments