From cfb796756d786863c71b982fd39faefac841a557 Mon Sep 17 00:00:00 2001 From: Aiden Date: Sat, 30 May 2026 14:43:33 +1000 Subject: [PATCH] Update ci.yml --- .gitea/workflows/ci.yml | 102 +++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 28 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index bd3efc4..9bdae74 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -23,25 +23,48 @@ jobs: env: GITEA_PAT: ${{ secrets.TOKEN }} run: | - $repoUrl = "https://aiden:${env:GITEA_PAT}@git.f-40.com/aiden/video-shader.git" - $submoduleUrl = "https://aiden:${env:GITEA_PAT}@git.f-40.com/aiden/video-io-3rdParty.git" + function Invoke-Git { + & git @args + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + } - git init . - git lfs install --local - git remote add origin "$repoUrl" - git fetch --depth=1 origin "${{ gitea.ref }}" - git checkout FETCH_HEAD + function Add-GiteaTokenToUrl([string]$url) { + if ([string]::IsNullOrWhiteSpace($env:GITEA_PAT)) { + return $url + } + return $url -replace "^https://", "https://aiden:$($env:GITEA_PAT)@" + } - git lfs pull origin "${{ gitea.ref }}" - git submodule sync --recursive - git config submodule.video-io-3rdParty.url "$submoduleUrl" - git submodule update --init --recursive --depth=1 - git -C video-io-3rdParty lfs pull + $serverUrl = "${{ gitea.server_url }}".TrimEnd("/") + $repository = "${{ gitea.repository }}" + if ([string]::IsNullOrWhiteSpace($serverUrl)) { + $serverUrl = "https://git.f-40.com" + } + if ([string]::IsNullOrWhiteSpace($repository)) { + $repository = "aiden/video-shader-toys" + } + $repoUrl = Add-GiteaTokenToUrl "$serverUrl/$repository.git" + + Invoke-Git init . + Invoke-Git lfs install --local + Invoke-Git remote add origin "$repoUrl" + Invoke-Git fetch --depth=1 origin "${{ gitea.ref }}" + Invoke-Git checkout FETCH_HEAD + + Invoke-Git lfs pull origin "${{ gitea.ref }}" + Invoke-Git submodule sync --recursive + $submoduleUrl = Invoke-Git config --file .gitmodules --get submodule.video-io-3rdParty.url + $submoduleUrl = Add-GiteaTokenToUrl "$submoduleUrl" + Invoke-Git config submodule.video-io-3rdParty.url "$submoduleUrl" + Invoke-Git submodule update --init --recursive --depth=1 + Invoke-Git -C video-io-3rdParty lfs pull Write-Host "Parent LFS files:" - git lfs ls-files + Invoke-Git lfs ls-files Write-Host "Submodule LFS files:" - git -C video-io-3rdParty lfs ls-files + Invoke-Git -C video-io-3rdParty lfs ls-files - name: Verify Visual Studio ATL shell: powershell @@ -162,25 +185,48 @@ jobs: env: GITEA_PAT: ${{ secrets.TOKEN }} run: | - $repoUrl = "https://aiden:${env:GITEA_PAT}@git.f-40.com/aiden/video-shader.git" - $submoduleUrl = "https://aiden:${env:GITEA_PAT}@git.f-40.com/aiden/video-io-3rdParty.git" + function Invoke-Git { + & git @args + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + } - git init . - git lfs install --local - git remote add origin "$repoUrl" - git fetch --depth=1 origin "${{ gitea.ref }}" - git checkout FETCH_HEAD + function Add-GiteaTokenToUrl([string]$url) { + if ([string]::IsNullOrWhiteSpace($env:GITEA_PAT)) { + return $url + } + return $url -replace "^https://", "https://aiden:$($env:GITEA_PAT)@" + } - git lfs pull origin "${{ gitea.ref }}" - git submodule sync --recursive - git config submodule.video-io-3rdParty.url "$submoduleUrl" - git submodule update --init --recursive --depth=1 - git -C video-io-3rdParty lfs pull + $serverUrl = "${{ gitea.server_url }}".TrimEnd("/") + $repository = "${{ gitea.repository }}" + if ([string]::IsNullOrWhiteSpace($serverUrl)) { + $serverUrl = "https://git.f-40.com" + } + if ([string]::IsNullOrWhiteSpace($repository)) { + $repository = "aiden/video-shader-toys" + } + $repoUrl = Add-GiteaTokenToUrl "$serverUrl/$repository.git" + + Invoke-Git init . + Invoke-Git lfs install --local + Invoke-Git remote add origin "$repoUrl" + Invoke-Git fetch --depth=1 origin "${{ gitea.ref }}" + Invoke-Git checkout FETCH_HEAD + + Invoke-Git lfs pull origin "${{ gitea.ref }}" + Invoke-Git submodule sync --recursive + $submoduleUrl = Invoke-Git config --file .gitmodules --get submodule.video-io-3rdParty.url + $submoduleUrl = Add-GiteaTokenToUrl "$submoduleUrl" + Invoke-Git config submodule.video-io-3rdParty.url "$submoduleUrl" + Invoke-Git submodule update --init --recursive --depth=1 + Invoke-Git -C video-io-3rdParty lfs pull Write-Host "Parent LFS files:" - git lfs ls-files + Invoke-Git lfs ls-files Write-Host "Submodule LFS files:" - git -C video-io-3rdParty lfs ls-files + Invoke-Git -C video-io-3rdParty lfs ls-files - name: Verify Visual Studio ATL shell: powershell