Skip to content

Commit 41db7cd

Browse files
committed
Allow easy syncing of F5 WAF images for e2e tests
1 parent 68ffc3b commit 41db7cd

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

.github/scripts/pull-nap-images.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
VERSION=$1
6+
DRY_RUN=${2:-false}
7+
NGINX_REPO=private-registry.nginx.com/nap
8+
DEV_REPO=gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/nap
9+
10+
docker pull "${NGINX_REPO}"/waf-config-mgr:"${VERSION}"
11+
docker pull "${NGINX_REPO}"/waf-enforcer:"${VERSION}"
12+
docker pull "${NGINX_REPO}"/waf-compiler:"${VERSION}"
13+
14+
docker tag "${NGINX_REPO}"/waf-config-mgr:"${VERSION}" "${DEV_REPO}"/waf-config-mgr:"${VERSION}"
15+
docker tag "${NGINX_REPO}"/waf-enforcer:"${VERSION}" "${DEV_REPO}"/waf-enforcer:"${VERSION}"
16+
docker tag "${NGINX_REPO}"/waf-compiler:"${VERSION}" "${DEV_REPO}"/waf-compiler:"${VERSION}"
17+
18+
if [ "${DRY_RUN}" = true ]; then
19+
echo "Dry run enabled, not pushing images"
20+
exit 0
21+
fi
22+
docker push "${DEV_REPO}"/waf-config-mgr:"${VERSION}"
23+
docker push "${DEV_REPO}"/waf-enforcer:"${VERSION}"
24+
docker push "${DEV_REPO}"/waf-compiler:"${VERSION}"
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Pull NAP Images
2+
run-name: ${{ inputs.dry_run && '[DRY RUN] ' || '' }}pull-nap-images - ${{ github.ref_name }} - ${{ inputs.version }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "Version to pull"
9+
required: true
10+
default: "latest"
11+
dry_run:
12+
description: "Don't push images"
13+
type: boolean
14+
default: false
15+
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
concurrency:
21+
group: ${{ github.ref_name }}-nap-images
22+
cancel-in-progress: true
23+
24+
permissions:
25+
contents: read
26+
27+
jobs:
28+
sync-nap-images:
29+
name: Pull NAP Images
30+
permissions:
31+
contents: read
32+
id-token: write
33+
runs-on: ubuntu-24.04
34+
steps:
35+
- name: Checkout Repository
36+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
37+
38+
- name: Azure login
39+
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
40+
with:
41+
client-id: ${{ secrets.AZURE_VAULT_CLIENT_ID }}
42+
tenant-id: ${{ secrets.AZURE_VAULT_TENANT_ID }}
43+
subscription-id: ${{ secrets.AZURE_VAULT_SUBSCRIPTION_ID }}
44+
45+
- name: Setup secrets
46+
id: secrets
47+
run: |
48+
echo "Setting secrets for job"
49+
GCR_WORKLOAD_ID=$(az keyvault secret show --name gcr-workload-identity --vault-name ${{ secrets.NIC_KEYVAULT_NAME }} --query value -o tsv)
50+
echo "::add-mask::$GCR_WORKLOAD_ID"
51+
echo "GCR_WORKLOAD_ID=$GCR_WORKLOAD_ID" >> $GITHUB_OUTPUT
52+
GCR_SERVICE_ACCOUNT=$(az keyvault secret show --name kic-pipeline-gcr-sa --vault-name ${{ secrets.NIC_KEYVAULT_NAME }} --query value -o tsv)
53+
echo "::add-mask::$GCR_SERVICE_ACCOUNT"
54+
echo "GCR_SERVICE_ACCOUNT=$GCR_SERVICE_ACCOUNT" >> $GITHUB_OUTPUT
55+
56+
- name: Authenticate to Google Cloud
57+
id: gcr-auth
58+
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
59+
with:
60+
token_format: access_token
61+
workload_identity_provider: ${{ steps.secrets.outputs.GCR_WORKLOAD_ID }}
62+
service_account: ${{ steps.secrets.outputs.GCR_SERVICE_ACCOUNT }}
63+
64+
- name: Login to GCR
65+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
66+
with:
67+
registry: gcr.io
68+
username: oauth2accesstoken
69+
password: ${{ steps.gcr-auth.outputs.access_token }}
70+
71+
- name: Get Id Token
72+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
73+
id: idtoken
74+
with:
75+
script: |
76+
let id_token = await core.getIDToken()
77+
core.setOutput('id_token', id_token)
78+
79+
- name: Login to NGINX Registry
80+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
81+
with:
82+
registry: docker-mgmt.nginx.com
83+
username: ${{ steps.idtoken.outputs.id_token }}
84+
password: ${{ github.actor }}
85+
86+
- name: Output Variables
87+
id: vars
88+
run: |
89+
./.github/scripts/pull-nap-images.sh "${{ inputs.version }}" "${{ inputs.dry_run }}"

0 commit comments

Comments
 (0)