Skip to content

Commit a1d1d34

Browse files
committed
az migration
1 parent 2a390ac commit a1d1d34

File tree

7 files changed

+114
-22
lines changed

7 files changed

+114
-22
lines changed

.github/workflows/azure-action.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Sync Secrets from Azure Key Vault
2+
author: s.breen
3+
description: az-sync
4+
inputs:
5+
az_client_id:
6+
description: 'Azure Client ID'
7+
required: true
8+
az_tenant_id:
9+
description: 'Azure Tenant ID'
10+
required: true
11+
az_subscription_id:
12+
description: 'Azure Subscription ID'
13+
required: true
14+
keyvault:
15+
description: 'Azure Key Vault name'
16+
required: true
17+
secrets-filter:
18+
description: 'Filter for secrets to sync (comma-separated patterns)'
19+
required: true
20+
default: '*'
21+
runs:
22+
using: "composite"
23+
steps:
24+
- name: Azure login
25+
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
26+
with:
27+
client-id: ${{ inputs.az_client_id }}
28+
tenant-id: ${{ inputs.az_tenant_id }}
29+
subscription-id: ${{ inputs.az_subscription_id }}
30+
31+
- name: Sync
32+
shell: bash
33+
run: |
34+
IFS=',' read -r -a array <<< "${{ inputs.secrets-filter }}"
35+
for pattern in "${array[@]}"; do
36+
echo "Processing pattern: $pattern"
37+
for secret_name in $(az keyvault secret list --vault-name "${{ inputs.keyvault }}" --query "[?contains(name, '$pattern')].name" -o tsv); do
38+
secret_value=$(az keyvault secret show --name "$secret_name" --vault-name "${{ inputs.keyvault }}" --query value -o tsv)
39+
# check if value is multiline
40+
if [[ "$secret_value" == *$'\n'* ]]; then
41+
# Mask each line for multiline secrets
42+
while IFS= read -r line; do
43+
[[ -n "$line" ]] && echo "::add-mask::${line}"
44+
done <<< "$secret_value"
45+
46+
# Use heredoc syntax for multiline environment variables
47+
delimiter="EOF_${secret_name}_$(date +%s)"
48+
{
49+
echo "${secret_name}<<${delimiter}"
50+
echo "$secret_value"
51+
echo "$delimiter"
52+
} >> $GITHUB_ENV
53+
else
54+
echo "::add-mask::${secret_value}"
55+
echo "$secret_name=$secret_value" >> $GITHUB_ENV
56+
fi
57+
echo "Synced secret: env.$secret_name"
58+
done
59+
done
60+
61+
- name: Azure logout
62+
shell: bash
63+
run: |
64+
az logout

.github/workflows/azure-upload.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
go-version-file: 'go.mod'
2222
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
2323
- run: npm install semver@7.6.2
24+
- name: Get Secrets from Azure Key Vault
25+
uses: ./.github/workflows/azure-action.yml
26+
with:
27+
az_client_id: ${{ secrets.AZ_KEYVAULT_CLIENT_ID }}
28+
az_tenant_id: ${{ secrets.AZ_KEYVAULT_TENANT_ID }}
29+
az_subscription_id: ${{ secrets.AZ_SUBSCRIPTION_ID }}
30+
keyvault: ${{ secrets.AZ_KEYVAULT_AGENT }}
31+
secrets-filter: 'artifactory'
2432
- name: Setup build environment
2533
run: |
2634
if [ "${{ env.ACT }}" = "true" ]; then
@@ -51,11 +59,7 @@ jobs:
5159
build-args: |
5260
package_type=signed-package
5361
- name: Build Packages
54-
env:
55-
INDIGO_GPG_AGENT: ${{ secrets.INDIGO_GPG_AGENT }}
56-
NFPM_SIGNING_KEY_FILE: .key.asc
5762
run: |
58-
echo "$INDIGO_GPG_AGENT" | base64 --decode > .key.asc
5963
make clean package
6064
- name: Azure Login
6165
uses: azure/login@6b2456866fc08b011acb422a92a4aa20e2c4de32 # v2.1.0

.github/workflows/ci.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,14 @@ jobs:
298298
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
299299
with:
300300
go-version-file: 'go.mod'
301+
- name: Get Secrets from Azure Key Vault
302+
uses: ./.github/workflows/azure-action.yml
303+
with:
304+
az_client_id: ${{ secrets.AZ_KEYVAULT_CLIENT_ID }}
305+
az_tenant_id: ${{ secrets.AZ_KEYVAULT_TENANT_ID }}
306+
az_subscription_id: ${{ secrets.AZ_SUBSCRIPTION_ID }}
307+
keyvault: ${{ secrets.AZ_KEYVAULT_AGENT }}
308+
secrets-filter: 'artifactory'
301309
- name: Download Packages
302310
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
303311
with:
@@ -306,9 +314,9 @@ jobs:
306314
- name: Login to Docker Registry
307315
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
308316
with:
309-
registry: ${{ secrets.TEST_REGISTRY_URL }}
310-
username: ${{ secrets.REGISTRY_USERNAME }}
311-
password: ${{ secrets.REGISTRY_PASSWORD }}
317+
registry: ${{ env.nginx-private-registry-url }}
318+
username: ${{ env.nginx-pkg-jwt }}
319+
password: "none"
312320
- name: Set Start Time
313321
run: echo "START_TIME=$(date +"%Y-%m-%dT%H:%M:%S.%NZ")" >> ${GITHUB_ENV}
314322
- name: Create Directory
@@ -320,8 +328,9 @@ jobs:
320328
- name: Run Integration Tests
321329
run: |
322330
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
323-
CONTAINER_NGINX_IMAGE_REGISTRY="${{ secrets.TEST_REGISTRY_URL }}" TAG="${{ matrix.container.plus }}-${{ matrix.container.image }}-${{ matrix.container.version }}" \
331+
CONTAINER_NGINX_IMAGE_REGISTRY="${{ env.nginx-private-registry-url }}" TAG="${{ matrix.container.plus }}-${{ matrix.container.image }}-${{ matrix.container.version }}" \
324332
OS_RELEASE="${{ matrix.container.release }}" IMAGE_PATH="${{ matrix.container.path }}" \
333+
NGINX_LICENSE_JWT='${{ env.nginx-pkg-jwt }}' \
325334
make official-image-integration-test | tee ${{github.workspace}}/test/dashboard/logs/${{github.job}}/${{matrix.container.image}}${{matrix.container.version}}/raw_logs.log && exit "${PIPESTATUS[0]}"
326335
- name: Generate Test Results
327336
if: always()
@@ -349,6 +358,14 @@ jobs:
349358
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
350359
- name: Set up Docker Build
351360
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
361+
- name: Get Secrets from Azure Key Vault
362+
uses: ./.github/workflows/azure-action.yml
363+
with:
364+
az_client_id: ${{ secrets.AZ_KEYVAULT_CLIENT_ID }}
365+
az_tenant_id: ${{ secrets.AZ_KEYVAULT_TENANT_ID }}
366+
az_subscription_id: ${{ secrets.AZ_SUBSCRIPTION_ID }}
367+
keyvault: ${{ secrets.AZ_KEYVAULT_AGENT }}
368+
secrets-filter: 'artifactory'
352369
- name: Build Docker Image
353370
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
354371
with:
@@ -359,8 +376,8 @@ jobs:
359376
load: true
360377
no-cache: true
361378
secrets: |
362-
"nginx-crt=${{ secrets.NGINX_CRT }}"
363-
"nginx-key=${{ secrets.NGINX_KEY }}"
379+
"nginx-crt=${{ env.nginx-pkg-certificate }}"
380+
"nginx-key=${{ env.nginx-pkg-key }}"
364381
- name: Run Performance Tests
365382
run: docker run -v ${GITHUB_WORKSPACE}:/home/nginx/ --rm nginx-agent-benchmark:1.0.0
366383

@@ -375,6 +392,14 @@ jobs:
375392
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
376393
with:
377394
go-version-file: 'go.mod'
395+
- name: Get Secrets from Azure Key Vault
396+
uses: ./.github/workflows/azure-action.yml
397+
with:
398+
az_client_id: ${{ secrets.AZ_KEYVAULT_CLIENT_ID }}
399+
az_tenant_id: ${{ secrets.AZ_KEYVAULT_TENANT_ID }}
400+
az_subscription_id: ${{ secrets.AZ_SUBSCRIPTION_ID }}
401+
keyvault: ${{ secrets.AZ_KEYVAULT_AGENT }}
402+
secrets-filter: 'artifactory'
378403
- name: Setup build environment
379404
run: |
380405
sudo apt-get update
@@ -394,11 +419,7 @@ jobs:
394419
build-args: |
395420
package_type=signed-package
396421
- name: Build Packages
397-
env:
398-
INDIGO_GPG_AGENT: ${{ secrets.INDIGO_GPG_AGENT }}
399-
NFPM_SIGNING_KEY_FILE: .key.asc
400422
run: |
401-
echo "$INDIGO_GPG_AGENT" | base64 --decode > .key.asc
402423
make clean package
403424
- name: Upload Artifacts
404425
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3

.github/workflows/f5-cla.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ jobs:
4747
# Do not lock PRs after a merge.
4848
lock-pullrequest-aftermerge: false
4949
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
GITHUB_TOKEN: ${{ github.token }}
5151
PERSONAL_ACCESS_TOKEN: ${{ secrets.F5_CLA_TOKEN }}

.github/workflows/label-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
with:
1919
disable-releaser: true
2020
env:
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/release-branch.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ jobs:
4747
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
4848
with:
4949
go-version-file: 'go.mod'
50-
50+
- name: Get Secrets from Azure Key Vault
51+
uses: ./.github/workflows/azure-action.yml
52+
with:
53+
az_client_id: ${{ secrets.AZ_KEYVAULT_CLIENT_ID }}
54+
az_tenant_id: ${{ secrets.AZ_KEYVAULT_TENANT_ID }}
55+
az_subscription_id: ${{ secrets.AZ_SUBSCRIPTION_ID }}
56+
keyvault: ${{ secrets.AZ_KEYVAULT_AGENT }}
57+
secrets-filter: 'artifactory'
5158
- name: Create Draft Release
5259
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
5360
id: release
@@ -165,11 +172,7 @@ jobs:
165172
package_type=signed-package
166173
167174
- name: Build Packages
168-
env:
169-
INDIGO_GPG_AGENT: ${{ secrets.INDIGO_GPG_AGENT }}
170-
NFPM_SIGNING_KEY_FILE: .key.asc
171175
run: |
172-
echo "$INDIGO_GPG_AGENT" | base64 --decode > .key.asc
173176
make clean package
174177
175178
- name: Get Id Token

Makefile.packaging

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $(GITHUB_PACKAGES_DIR):
4141
$(AZURE_PACKAGES_DIR):
4242
@mkdir -p $(AZURE_PACKAGES_DIR)
4343

44-
package: gpg-key $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) $(AZURE_PACKAGES_DIR) #### Create final packages for all supported distros
44+
package: $(PACKAGES_DIR) $(GITHUB_PACKAGES_DIR) $(AZURE_PACKAGES_DIR) #### Create final packages for all supported distros
4545
# Create deb packages
4646

4747
@for arch in $(DEB_ARCHS); do \

0 commit comments

Comments
 (0)