@@ -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
5155outputs :
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 # --------------------------------------------------------------------
0 commit comments