From f825c72ca299bebd00b12570c08692456a935806 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Thu, 28 May 2026 17:12:49 +0330 Subject: [PATCH] perf(ci): replace apk add git with Gitea archive API for Node.js jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit apk add git downloads from dl-cdn.alpinelinux.org (Fastly CDN) which is slow/blocked in Iran — caused 6m+ checkout times. New approach: wget the repo tarball from Gitea's archive API endpoint. wget + tar (busybox) are already in node:20-alpine — no package install. Gitea is on the same machine as the runner = download is instant. GET /api/v1/repos/{owner}/{repo}/archive/{sha}.tar.gz Authorization: Bearer {token} dotnet/sdk jobs unchanged — Debian base has git pre-installed. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/ci-cd.yml | 64 +++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index a74fc6a..65904cc 100644 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -147,14 +147,16 @@ jobs: - name: Checkout env: TOKEN: ${{ github.token }} - REF: ${{ github.ref }} + SHA: ${{ github.sha }} run: | - apk add --no-cache git - git init - git remote add origin "${{ github.server_url }}/${{ github.repository }}.git" - git config http.extraheader "Authorization: Bearer ${TOKEN}" - git fetch --depth=1 origin "${REF}" - git checkout FETCH_HEAD + # No apk install needed — wget + tar (busybox) are pre-installed in node:20-alpine. + # Downloads the repo tarball directly from Gitea (same machine = instant). + wget -q \ + --header "Authorization: Bearer ${TOKEN}" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/archive/${SHA}.tar.gz" \ + -O /tmp/repo.tar.gz + tar -xzf /tmp/repo.tar.gz --strip-components=1 + rm -f /tmp/repo.tar.gz - name: Install dependencies working-directory: web/dashboard @@ -179,14 +181,16 @@ jobs: - name: Checkout env: TOKEN: ${{ github.token }} - REF: ${{ github.ref }} + SHA: ${{ github.sha }} run: | - apk add --no-cache git - git init - git remote add origin "${{ github.server_url }}/${{ github.repository }}.git" - git config http.extraheader "Authorization: Bearer ${TOKEN}" - git fetch --depth=1 origin "${REF}" - git checkout FETCH_HEAD + # No apk install needed — wget + tar (busybox) are pre-installed in node:20-alpine. + # Downloads the repo tarball directly from Gitea (same machine = instant). + wget -q \ + --header "Authorization: Bearer ${TOKEN}" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/archive/${SHA}.tar.gz" \ + -O /tmp/repo.tar.gz + tar -xzf /tmp/repo.tar.gz --strip-components=1 + rm -f /tmp/repo.tar.gz - name: Install dependencies working-directory: web/admin @@ -211,14 +215,16 @@ jobs: - name: Checkout env: TOKEN: ${{ github.token }} - REF: ${{ github.ref }} + SHA: ${{ github.sha }} run: | - apk add --no-cache git - git init - git remote add origin "${{ github.server_url }}/${{ github.repository }}.git" - git config http.extraheader "Authorization: Bearer ${TOKEN}" - git fetch --depth=1 origin "${REF}" - git checkout FETCH_HEAD + # No apk install needed — wget + tar (busybox) are pre-installed in node:20-alpine. + # Downloads the repo tarball directly from Gitea (same machine = instant). + wget -q \ + --header "Authorization: Bearer ${TOKEN}" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/archive/${SHA}.tar.gz" \ + -O /tmp/repo.tar.gz + tar -xzf /tmp/repo.tar.gz --strip-components=1 + rm -f /tmp/repo.tar.gz - name: Install dependencies working-directory: web/website @@ -243,14 +249,16 @@ jobs: - name: Checkout env: TOKEN: ${{ github.token }} - REF: ${{ github.ref }} + SHA: ${{ github.sha }} run: | - apk add --no-cache git - git init - git remote add origin "${{ github.server_url }}/${{ github.repository }}.git" - git config http.extraheader "Authorization: Bearer ${TOKEN}" - git fetch --depth=1 origin "${REF}" - git checkout FETCH_HEAD + # No apk install needed — wget + tar (busybox) are pre-installed in node:20-alpine. + # Downloads the repo tarball directly from Gitea (same machine = instant). + wget -q \ + --header "Authorization: Bearer ${TOKEN}" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/archive/${SHA}.tar.gz" \ + -O /tmp/repo.tar.gz + tar -xzf /tmp/repo.tar.gz --strip-components=1 + rm -f /tmp/repo.tar.gz - name: Install dependencies working-directory: web/finder