Skip to content

Commit eefd60c

Browse files
committed
Configure goproxy in each step
1 parent 15a59b8 commit eefd60c

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
min_k8s_version: ${{ steps.vars.outputs.min_k8s_version }}
4646
k8s_latest: ${{ steps.vars.outputs.k8s_latest }}
4747
helm_changes: ${{ steps.filter.outputs.charts }}
48-
goproxy: ${{ steps.goproxy.outputs.goproxy }}
4948
steps:
5049
- name: Checkout Repository
5150
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -64,7 +63,6 @@ jobs:
6463
echo "Development mode - using dev Artifactory"
6564
GOPROXY_VALUE="https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_DEV_ENDPOINT }}"
6665
fi
67-
echo "goproxy=${GOPROXY_VALUE}" >> $GITHUB_OUTPUT
6866
echo "GOPROXY=${GOPROXY_VALUE}" >> $GITHUB_ENV
6967
7068
- name: Setup Golang Environment
@@ -105,12 +103,20 @@ jobs:
105103
name: Unit Tests
106104
runs-on: ubuntu-24.04
107105
needs: vars
108-
env:
109-
GOPROXY: ${{ needs.vars.outputs.goproxy }}
110106
steps:
111107
- name: Checkout Repository
112108
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
113109

110+
- name: Configure GOPROXY
111+
id: goproxy
112+
run: |
113+
if [[ "${{ secrets.ARTIFACTORY_USER }}" == "" ]]; then
114+
GOPROXY_VALUE="direct"
115+
else
116+
GOPROXY_VALUE="https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_DEV_ENDPOINT }}"
117+
fi
118+
echo "GOPROXY=${GOPROXY_VALUE}" >> $GITHUB_ENV
119+
114120
- name: Setup Golang Environment
115121
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
116122
with:
@@ -159,8 +165,6 @@ jobs:
159165
name: Build Binary
160166
runs-on: ${{ github.repository_owner == 'nginx' && (inputs.is_production_release || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && 'ubuntu-24.04-amd64' || 'ubuntu-24.04' }}
161167
needs: [vars, unit-tests, njs-unit-tests]
162-
env:
163-
GOPROXY: ${{ needs.vars.outputs.goproxy }}
164168
outputs:
165169
json: ${{ steps.gateway_binaries.outputs.json }}
166170
permissions:
@@ -173,6 +177,21 @@ jobs:
173177
with:
174178
fetch-depth: 0
175179

180+
- name: Configure GOPROXY
181+
id: goproxy
182+
run: |
183+
if [[ "${{ secrets.ARTIFACTORY_USER }}" == "" ]]; then
184+
echo "No Artifactory secrets available - using direct GOPROXY"
185+
GOPROXY_VALUE="direct"
186+
elif [[ "${{ inputs.is_production_release }}" == "true" ]] || [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
187+
echo "Production mode - using production Artifactory"
188+
GOPROXY_VALUE="https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_ENDPOINT }}"
189+
else
190+
echo "Development mode - using dev Artifactory"
191+
GOPROXY_VALUE="https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_DEV_ENDPOINT }}"
192+
fi
193+
echo "GOPROXY=${GOPROXY_VALUE}" >> $GITHUB_ENV
194+
176195
- name: Setup Golang Environment
177196
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
178197
with:
@@ -254,8 +273,6 @@ jobs:
254273
permissions:
255274
contents: read
256275
id-token: write # for compliance-rules action to sign assertion doc
257-
env:
258-
GOPROXY: ${{ needs.vars.outputs.goproxy }}
259276
runs-on: ubuntu-24.04
260277
strategy:
261278
fail-fast: false
@@ -265,6 +282,21 @@ jobs:
265282
- name: Checkout Repository
266283
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
267284

285+
- name: Configure GOPROXY
286+
id: goproxy
287+
run: |
288+
if [[ "${{ secrets.ARTIFACTORY_USER }}" == "" ]]; then
289+
echo "No Artifactory secrets available - using direct GOPROXY"
290+
GOPROXY_VALUE="direct"
291+
elif [[ "${{ inputs.is_production_release }}" == "true" ]] || [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
292+
echo "Production mode - using production Artifactory"
293+
GOPROXY_VALUE="https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_ENDPOINT }}"
294+
else
295+
echo "Development mode - using dev Artifactory"
296+
GOPROXY_VALUE="https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_DEV_ENDPOINT }}"
297+
fi
298+
echo "GOPROXY=${GOPROXY_VALUE}" >> $GITHUB_ENV
299+
268300
- name: Setup Golang Environment
269301
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
270302
with:
@@ -445,12 +477,20 @@ jobs:
445477
name: CEL Tests
446478
runs-on: ubuntu-24.04
447479
needs: vars
448-
env:
449-
GOPROXY: ${{ needs.vars.outputs.goproxy }}
450480
steps:
451481
- name: Checkout Repository
452482
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
453483

484+
- name: Configure GOPROXY
485+
id: goproxy
486+
run: |
487+
if [[ "${{ secrets.ARTIFACTORY_USER }}" == "" ]]; then
488+
GOPROXY_VALUE="direct"
489+
else
490+
GOPROXY_VALUE="https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_DEV_ENDPOINT }}"
491+
fi
492+
echo "GOPROXY=${GOPROXY_VALUE}" >> $GITHUB_ENV
493+
454494
- name: Setup Golang Environment
455495
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
456496
with:

0 commit comments

Comments
 (0)