Skip to content

Commit c680eef

Browse files
authored
Add GOPROXY to binary builds (#8053)
1 parent c315a25 commit c680eef

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
k8s_latest: ${{ steps.vars.outputs.k8s_latest }}
4444
go_path: ${{ steps.vars.outputs.go_path }}
4545
go_code_md5: ${{ steps.vars.outputs.go_code_md5 }}
46+
go_proxy: ${{ steps.vars.outputs.go_proxy }}
4647
binary_cache_hit: ${{ steps.binary-cache.outputs.cache-hit }}
4748
chart_version: ${{ steps.vars.outputs.chart_version }}
4849
ic_version: ${{ steps.vars.outputs.ic_version }}
@@ -98,7 +99,13 @@ jobs:
9899
source .github/data/version.txt
99100
echo "ic_version=${IC_VERSION}" >> $GITHUB_OUTPUT
100101
echo "chart_version=${HELM_CHART_VERSION}" >> $GITHUB_OUTPUT
101-
echo "forked_workflow=${{ (github.event.pull_request && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) || github.repository != 'nginx/kubernetes-ingress' }}" >> $GITHUB_OUTPUT
102+
forked_workflow=${{ (github.event.pull_request && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) || github.repository != 'nginx/kubernetes-ingress' }}
103+
echo "forked_workflow=${forked_workflow}" >> $GITHUB_OUTPUT
104+
go_proxy="https://proxy.golang.org,direct"
105+
if [ "$forked_workflow" = "false" ]; then
106+
go_proxy="https://azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-dev"
107+
fi
108+
echo "go_proxy=${go_proxy}" >> $GITHUB_OUTPUT
102109
./.github/scripts/variables.sh go_code_md5 >> $GITHUB_OUTPUT
103110
./.github/scripts/variables.sh docker_md5 >> $GITHUB_OUTPUT
104111
./.github/scripts/variables.sh build_tag >> $GITHUB_OUTPUT
@@ -173,6 +180,8 @@ jobs:
173180
permissions:
174181
contents: read
175182
needs: checks
183+
env:
184+
GOPROXY: ${{ needs.checks.outputs.go_proxy }}
176185
steps:
177186
- name: Checkout Repository
178187
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -183,6 +192,16 @@ jobs:
183192
go-version-file: go.mod
184193
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
185194

195+
- name: Setup netrc
196+
run: |
197+
cat <<EOF > $HOME/.netrc
198+
machine azr.artifactory.f5net.com
199+
login ${{ secrets.ARTIFACTORY_USER }}
200+
password ${{ secrets.ARTIFACTORY_TOKEN }}
201+
EOF
202+
chmod 600 $HOME/.netrc
203+
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' && needs.checks.outputs.forked_workflow != 'true' }}
204+
186205
- name: Check if go.mod and go.sum are up to date
187206
run: go mod tidy && git diff --exit-code -- go.mod go.sum
188207
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
@@ -212,6 +231,8 @@ jobs:
212231
name: Unit Tests
213232
runs-on: ubuntu-22.04
214233
needs: checks
234+
env:
235+
GOPROXY: ${{ needs.checks.outputs.go_proxy }}
215236
steps:
216237
- name: Checkout Repository
217238
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -222,6 +243,16 @@ jobs:
222243
go-version-file: go.mod
223244
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' && (inputs.run_tests && inputs.run_tests || true) }}
224245

246+
- name: Setup netrc
247+
run: |
248+
cat <<EOF > $HOME/.netrc
249+
machine azr.artifactory.f5net.com
250+
login ${{ secrets.ARTIFACTORY_USER }}
251+
password ${{ secrets.ARTIFACTORY_TOKEN }}
252+
EOF
253+
chmod 600 $HOME/.netrc
254+
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' && needs.checks.outputs.forked_workflow != 'true' }}
255+
225256
- name: Run Tests
226257
run: make cover
227258
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' && (inputs.run_tests && inputs.run_tests || true) }}
@@ -260,6 +291,16 @@ jobs:
260291
go-version-file: go.mod
261292
if: ${{ (inputs.force && inputs.force || false) || needs.checks.outputs.binary_cache_hit != 'true' }}
262293

294+
- name: Setup netrc
295+
run: |
296+
cat <<EOF > $HOME/.netrc
297+
machine azr.artifactory.f5net.com
298+
login ${{ secrets.ARTIFACTORY_USER }}
299+
password ${{ secrets.ARTIFACTORY_TOKEN }}
300+
EOF
301+
chmod 600 $HOME/.netrc
302+
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' && needs.checks.outputs.forked_workflow != 'true' }}
303+
263304
- name: Build binaries
264305
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
265306
with:
@@ -268,6 +309,7 @@ jobs:
268309
env:
269310
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
270311
GOPATH: ${{ needs.checks.outputs.go_path }}
312+
GOPROXY: ${{ needs.checks.outputs.go_proxy }}
271313
AWS_PRODUCT_CODE: ${{ secrets.AWS_PRODUCT_CODE }}
272314
AWS_PUB_KEY: ${{ secrets.AWS_PUB_KEY }}
273315
AWS_NAP_DOS_PRODUCT_CODE: ${{ secrets.AWS_NAP_DOS_PRODUCT_CODE }}

.github/workflows/image-promotion.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
outputs:
3737
go_path: ${{ steps.vars.outputs.go_path }}
3838
go_code_md5: ${{ steps.vars.outputs.go_code_md5 }}
39+
go_proxy: ${{ steps.vars.outputs.go_proxy }}
3940
binary_cache_hit: ${{ steps.binary-cache.outputs.cache-hit }}
4041
chart_version: ${{ steps.vars.outputs.chart_version }}
4142
ic_version: ${{ steps.vars.outputs.ic_version }}
@@ -58,7 +59,7 @@ jobs:
5859
- name: Set Variables
5960
id: vars
6061
run: |
61-
echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT
62+
echo "go_proxy="https://azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-dev" >> $GITHUB_OUTPUT
6263
source .github/data/version.txt
6364
echo "ic_version=${IC_VERSION}" >> $GITHUB_OUTPUT
6465
echo "chart_version=${HELM_CHART_VERSION}" >> $GITHUB_OUTPUT
@@ -118,6 +119,9 @@ jobs:
118119
permissions:
119120
contents: read
120121
security-events: write
122+
needs: [checks]
123+
env:
124+
GOPROXY: ${{ needs.checks.outputs.go_proxy }}
121125
steps:
122126
- name: Checkout Repository
123127
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -127,6 +131,15 @@ jobs:
127131
with:
128132
go-version-file: go.mod
129133

134+
- name: Setup netrc
135+
run: |
136+
cat <<EOF > $HOME/.netrc
137+
machine azr.artifactory.f5net.com
138+
login ${{ secrets.ARTIFACTORY_USER }}
139+
password ${{ secrets.ARTIFACTORY_TOKEN }}
140+
EOF
141+
chmod 600 $HOME/.netrc
142+
130143
- name: govulncheck
131144
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
132145
with:
@@ -164,6 +177,16 @@ jobs:
164177
go-version-file: go.mod
165178
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
166179

180+
- name: Setup netrc
181+
run: |
182+
cat <<EOF > $HOME/.netrc
183+
machine azr.artifactory.f5net.com
184+
login ${{ secrets.ARTIFACTORY_USER }}
185+
password ${{ secrets.ARTIFACTORY_TOKEN }}
186+
EOF
187+
chmod 600 $HOME/.netrc
188+
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
189+
167190
- name: Build binaries
168191
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
169192
with:
@@ -172,6 +195,7 @@ jobs:
172195
env:
173196
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
174197
GOPATH: ${{ needs.checks.outputs.go_path }}
198+
GOPROXY: ${{ needs.checks.outputs.go_proxy }}
175199
AWS_PRODUCT_CODE: ${{ secrets.AWS_PRODUCT_CODE }}
176200
AWS_PUB_KEY: ${{ secrets.AWS_PUB_KEY }}
177201
AWS_NAP_DOS_PRODUCT_CODE: ${{ secrets.AWS_NAP_DOS_PRODUCT_CODE }}

0 commit comments

Comments
 (0)