Skip to content

Commit 25a1520

Browse files
authored
sync(ci): add private Go module auth support to workflows (#290)
1 parent 03bc0f9 commit 25a1520

15 files changed

+98
-11
lines changed

.github/actions/setup-go-with-cache/action.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ inputs:
4747
description: "Enable multi-module mode - uses pattern **/go.sum to hash all go.sum files for cache keys, skips root go.sum validation"
4848
required: false
4949
default: "false"
50+
github-token:
51+
description: "GitHub token for private module authentication (only used when GOPRIVATE is set in environment)"
52+
required: false
53+
default: ""
5054

5155
outputs:
5256
go-version-actual:
@@ -443,6 +447,32 @@ runs:
443447
go-version: ${{ inputs.go-version }}
444448
cache: false # we handle caches ourselves
445449

450+
# --------------------------------------------------------------------
451+
# Configure git authentication for private Go modules (conditional)
452+
# Only runs when GOPRIVATE is set AND a github-token is provided
453+
# --------------------------------------------------------------------
454+
- name: 🔐 Configure private module authentication
455+
if: ${{ inputs.github-token != '' && env.GOPRIVATE != '' }}
456+
shell: bash
457+
run: |
458+
echo "🔐 Configuring git authentication for private Go modules..."
459+
echo "📋 GOPRIVATE=$GOPRIVATE"
460+
461+
# Configure git to use the token for HTTPS URLs
462+
git config --global url."https://x-access-token:${{ inputs.github-token }}@github.com/".insteadOf "https://github.com/"
463+
464+
# Set GONOSUMCHECK to match GOPRIVATE if not explicitly set
465+
if [ -z "$GONOSUMCHECK" ]; then
466+
echo "GONOSUMCHECK=$GOPRIVATE" >> $GITHUB_ENV
467+
fi
468+
469+
# Set GONOSUMDB to match GOPRIVATE if not explicitly set
470+
if [ -z "$GONOSUMDB" ]; then
471+
echo "GONOSUMDB=$GOPRIVATE" >> $GITHUB_ENV
472+
fi
473+
474+
echo "✅ Private module authentication configured"
475+
446476
# --------------------------------------------------------------------
447477
# Summary and validation
448478
# --------------------------------------------------------------------

.github/actions/warm-cache/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ inputs:
5353
description: "Enable multi-module mode - uses hash of all go.sum files for cache keys"
5454
required: false
5555
default: "false"
56+
github-token:
57+
description: "GitHub token for private module authentication (only used when GOPRIVATE is set)"
58+
required: false
59+
default: ""
5660

5761
runs:
5862
using: "composite"
@@ -96,6 +100,7 @@ runs:
96100
go-secondary-version: ${{ inputs.go-secondary-version }}
97101
go-sum-file: ${{ inputs.go-sum-file }}
98102
enable-multi-module: ${{ inputs.enable-multi-module }}
103+
github-token: ${{ inputs.github-token }}
99104

100105
# ────────────────────────────────────────────────────────────────────────────
101106
# Setup MAGE-X (required for magex commands in cache warming)

.github/env/00-core.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ GO_SUM_FILE=go.sum
4141
# Multi-module monorepo support
4242
ENABLE_MULTI_MODULE_TESTING=false
4343

44+
# Private Go module support (opt-in)
45+
# Set GOPRIVATE in 90-project.env to enable private module authentication
46+
# Example: github.com/myorg/*,github.com/otherorg/*
47+
GOPRIVATE=
48+
GONOSUMCHECK=
49+
GONOSUMDB=
50+
4451
# ================================================================================================
4552
# 🖥️ RUNNER CONFIGURATION
4653
# ================================================================================================

.github/workflows/fortress-benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ jobs:
144144
go-secondary-version: ${{ inputs.go-secondary-version }}
145145
go-sum-file: ${{ inputs.go-sum-file }}
146146
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
147+
github-token: ${{ secrets.github-token }}
147148

148149
# --------------------------------------------------------------------
149150
# Extract Go module directory from GO_SUM_FILE path

.github/workflows/fortress-code-quality.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ jobs:
9494
go-secondary-version: ${{ inputs.go-primary-version }}
9595
go-sum-file: ${{ env.GO_SUM_FILE }}
9696
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
97+
github-token: ${{ secrets.github-token }}
9798

9899
# --------------------------------------------------------------------
99100
# Extract Go module directory from GO_SUM_FILE path
@@ -316,6 +317,7 @@ jobs:
316317
go-secondary-version: ${{ inputs.go-primary-version }}
317318
go-sum-file: ${{ env.GO_SUM_FILE }}
318319
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
320+
github-token: ${{ secrets.github-token }}
319321

320322
# --------------------------------------------------------------------
321323
# Extract Go module directory from GO_SUM_FILE path
@@ -596,6 +598,7 @@ jobs:
596598
go-secondary-version: ${{ inputs.go-primary-version }}
597599
go-sum-file: ${{ env.GO_SUM_FILE }}
598600
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
601+
github-token: ${{ secrets.github-token }}
599602

600603
# --------------------------------------------------------------------
601604
# Extract Go module directory from GO_SUM_FILE path

.github/workflows/fortress-coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ jobs:
176176
go-secondary-version: ${{ env.GO_SECONDARY_VERSION }}
177177
go-sum-file: ${{ inputs.go-sum-file }}
178178
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
179+
github-token: ${{ secrets.github-token }}
179180

180181
# --------------------------------------------------------------------
181182
# Extract Go module directory from GO_SUM_FILE path

.github/workflows/fortress-pre-commit.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ on:
3333
description: "Path to go.sum file for dependency verification"
3434
required: true
3535
type: string
36+
secrets:
37+
github-token:
38+
description: "GitHub token for private module authentication (optional, only needed when GOPRIVATE is set)"
39+
required: false
3640
outputs:
3741
pre-commit-version:
3842
description: "Version of go-pre-commit used"
@@ -87,6 +91,7 @@ jobs:
8791
go-secondary-version: ${{ inputs.go-primary-version }}
8892
go-sum-file: ${{ env.GO_SUM_FILE }}
8993
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
94+
github-token: ${{ secrets.github-token }}
9095

9196
# --------------------------------------------------------------------
9297
# Extract Go module directory from GO_SUM_FILE path

.github/workflows/fortress-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
go-secondary-version: ${{ inputs.go-primary-version }}
9292
go-sum-file: ${{ inputs.go-sum-file }}
9393
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
94+
github-token: ${{ secrets.github-token }}
9495

9596
# --------------------------------------------------------------------
9697
# Validate version tag format

.github/workflows/fortress-security-scans.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ jobs:
9999
go-secondary-version: ${{ inputs.go-primary-version }}
100100
go-sum-file: ${{ inputs.go-sum-file }}
101101
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
102+
github-token: ${{ secrets.github-token }}
102103

103104
# --------------------------------------------------------------------
104105
# Extract Go module directory from GO_SUM_FILE path
@@ -297,6 +298,7 @@ jobs:
297298
go-secondary-version: ${{ inputs.go-primary-version }}
298299
go-sum-file: ${{ inputs.go-sum-file }}
299300
enable-multi-module: ${{ env.ENABLE_MULTI_MODULE_TESTING }}
301+
github-token: ${{ secrets.github-token }}
300302

301303
# --------------------------------------------------------------------
302304
# Extract Go module directory from GO_SUM_FILE path

.github/workflows/fortress-setup-config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,13 @@ jobs:
568568
echo "| **Features** | $ENABLED_FEATURES enabled · $DISABLED_FEATURES disabled |" >> $GITHUB_STEP_SUMMARY
569569
echo "| **Test Matrix** | $MATRIX_COUNT combinations |" >> $GITHUB_STEP_SUMMARY
570570
echo "| **Go Versions** | $(echo "$UNIQUE_GO_VERSIONS" | jq -r 'join(", ")') |" >> $GITHUB_STEP_SUMMARY
571+
572+
# Show private module status if GOPRIVATE is configured
573+
GOPRIVATE_VAL=$(echo "$ENV_JSON" | jq -r '.GOPRIVATE // ""')
574+
if [ -n "$GOPRIVATE_VAL" ]; then
575+
echo "| **Private Modules** | \`$GOPRIVATE_VAL\` |" >> $GITHUB_STEP_SUMMARY
576+
fi
577+
571578
echo "" >> $GITHUB_STEP_SUMMARY
572579
573580
# Fork PR Warning (if applicable) - this stays visible

0 commit comments

Comments
 (0)