From b2fcbf82dee6003ddbde49cd0197bfa13f26d5ae Mon Sep 17 00:00:00 2001 From: logikonline Date: Tue, 27 Jan 2026 23:56:32 -0500 Subject: [PATCH] refactor(ci): simplify vault dependency handling in build workflow Replace complex vault version fetching and go.mod rewriting with direct git clone of vault dependency. This simplifies the build process by using the local replace directive in go.mod instead of dynamically updating to a specific version. Remove API calls to fetch latest vault version and eliminate go.mod manipulation steps. The vault repository is now cloned once at the start of each job. --- .gitea/workflows/build.yml | 73 +++++++------------------------------- 1 file changed, 13 insertions(+), 60 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index bfeab95696..06be3a2f6e 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -25,22 +25,14 @@ jobs: name: Lint runs-on: linux-latest steps: - - name: Get latest vault version - id: vault - run: | - VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4) - echo "version=$VERSION" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - name: Checkout code uses: actions/checkout@v4 - - name: Configure private repo access + - name: Clone vault dependency env: - RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} + VAULT_TOKEN: ${{ secrets.RELEASE_TOKEN }} run: | - git config --global url."https://token:${RELEASE_TOKEN}@git.marketally.com/".insteadOf "https://git.marketally.com/" - git config --global url."https://token:${RELEASE_TOKEN}@direct.git.marketally.com/".insteadOf "https://direct.git.marketally.com/" + git clone --depth 1 "https://token:${VAULT_TOKEN}@git.marketally.com/gitcaddy/gitcaddy-vault.git" ../gitcaddy-vault - name: Setup Go uses: actions/setup-go@v5 @@ -48,16 +40,8 @@ jobs: go-version: ${{ env.GO_VERSION }} cache: false - - name: Update vault dependency - env: - GOPRIVATE: "" - run: | - set -x - VAULT_VERSION="${{ steps.vault.outputs.version }}" - echo "Building with vault $VAULT_VERSION" - sed -i "s|replace git.marketally.com/gitcaddy/gitcaddy-vault => ../gitcaddy-vault|replace git.marketally.com/gitcaddy/gitcaddy-vault => git.marketally.com/gitcaddy/gitcaddy-vault $VAULT_VERSION|" go.mod - cat go.mod | grep -A2 "gitcaddy-vault" || true - go mod tidy -v 2>&1 + - name: Tidy modules + run: go mod tidy - name: Setup Node.js uses: actions/setup-node@v4 @@ -82,21 +66,14 @@ jobs: name: Unit Tests runs-on: linux-latest steps: - - name: Get latest vault version - id: vault - run: | - VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4) - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - name: Checkout code uses: actions/checkout@v4 - - name: Configure private repo access + - name: Clone vault dependency env: - RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} + VAULT_TOKEN: ${{ secrets.RELEASE_TOKEN }} run: | - git config --global url."https://token:${RELEASE_TOKEN}@git.marketally.com/".insteadOf "https://git.marketally.com/" - git config --global url."https://token:${RELEASE_TOKEN}@direct.git.marketally.com/".insteadOf "https://direct.git.marketally.com/" + git clone --depth 1 "https://token:${VAULT_TOKEN}@git.marketally.com/gitcaddy/gitcaddy-vault.git" ../gitcaddy-vault - name: Setup Go uses: actions/setup-go@v5 @@ -104,16 +81,6 @@ jobs: go-version: ${{ env.GO_VERSION }} cache: false - - name: Update vault dependency - env: - GOPRIVATE: "" - run: | - set -x - VAULT_VERSION="${{ steps.vault.outputs.version }}" - sed -i "s|replace git.marketally.com/gitcaddy/gitcaddy-vault => ../gitcaddy-vault|replace git.marketally.com/gitcaddy/gitcaddy-vault => git.marketally.com/gitcaddy/gitcaddy-vault $VAULT_VERSION|" go.mod - cat go.mod | grep -A2 "gitcaddy-vault" || true - go mod tidy -v 2>&1 - - name: Install dependencies run: go mod download @@ -146,21 +113,14 @@ jobs: ports: - 5432:5432 steps: - - name: Get latest vault version - id: vault - run: | - VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-vault/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4) - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - name: Checkout code uses: actions/checkout@v4 - - name: Configure private repo access + - name: Clone vault dependency env: - RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} + VAULT_TOKEN: ${{ secrets.RELEASE_TOKEN }} run: | - git config --global url."https://token:${RELEASE_TOKEN}@git.marketally.com/".insteadOf "https://git.marketally.com/" - git config --global url."https://token:${RELEASE_TOKEN}@direct.git.marketally.com/".insteadOf "https://direct.git.marketally.com/" + git clone --depth 1 "https://token:${VAULT_TOKEN}@git.marketally.com/gitcaddy/gitcaddy-vault.git" ../gitcaddy-vault - name: Setup Go uses: actions/setup-go@v5 @@ -168,15 +128,8 @@ jobs: go-version: ${{ env.GO_VERSION }} cache: false - - name: Update vault dependency - env: - GOPRIVATE: "" - run: | - set -x - VAULT_VERSION="${{ steps.vault.outputs.version }}" - sed -i "s|replace git.marketally.com/gitcaddy/gitcaddy-vault => ../gitcaddy-vault|replace git.marketally.com/gitcaddy/gitcaddy-vault => git.marketally.com/gitcaddy/gitcaddy-vault $VAULT_VERSION|" go.mod - cat go.mod | grep -A2 "gitcaddy-vault" || true - go mod tidy -v 2>&1 + - name: Tidy modules + run: go mod tidy - name: Setup Node.js uses: actions/setup-node@v4