1+ name : Publish Support Images
2+ on :
3+ workflow_dispatch : {}
4+
5+ # Supports out-of-band publishing of supporting images, such as kube-webhook-certgen.
6+ # We also handle publishing of these supporting images in the main release workflow,
7+ # but this allows us to publish updates to these images without needing to cut a new release
8+ # of the entire ingress-nginx controller.
9+
10+ permissions :
11+ contents : read
12+
13+ jobs :
14+ kube-webhook-certgen :
15+ permissions :
16+ contents : read
17+ id-token : write # needed for the Vault authentication
18+
19+ runs-on : ubuntu-latest
20+ steps :
21+ - name : Check out code
22+ uses : actions/checkout@v6
23+
24+ # This is a roundabout OP, since the Makefile defaults to this value,
25+ # but the publish-image action requires a tag, that it then passses to the Makefile
26+ - name : Set Tag
27+ run : |
28+ KWC_TAG=$(cat ./images/kube-webhook-certgen/TAG)
29+ echo "KWC_TAG=$KWC_TAG" >> $GITHUB_ENV
30+
31+ # Only pull vault secrets if the repository is rancher
32+ - name : " Read secrets"
33+ if : github.repository_owner == 'rancher'
34+ uses : rancher-eio/read-vault-secrets@main
35+ with :
36+ secrets : |
37+ secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
38+ secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_TOKEN ;
39+ secret/data/github/repo/${{ github.repository }}/rancher-prime-registry/credentials registry | PRIME_REGISTRY ;
40+ secret/data/github/repo/${{ github.repository }}/rancher-prime-registry/credentials username | PRIME_REGISTRY_USERNAME ;
41+ secret/data/github/repo/${{ github.repository }}/rancher-prime-registry/credentials password | PRIME_REGISTRY_PASSWORD
42+
43+ - name : Check if image already exists on DockerHub
44+ id : certgen_exists
45+ run : |
46+ REPO="${{ github.repository_owner }}/kube-webhook-certgen"
47+ STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://hub.docker.com/v2/repositories/${REPO}/tags/${KWC_TAG}")
48+ if [[ "$STATUS" == "200" ]]; then
49+ echo "exists=true" >> "$GITHUB_OUTPUT"
50+ else
51+ echo "exists=false" >> "$GITHUB_OUTPUT"
52+ fi
53+
54+ - name : Check if image already exists on Prime Registry
55+ id : prime_certgen_exists
56+ run : |
57+ # Short-circuit and assume the image exists if this is not the rancher repository
58+ if [[ "${{ github.repository_owner }}" != "rancher" ]]; then
59+ echo "prime_exists=true" >> "$GITHUB_OUTPUT"
60+ exit 0
61+ fi
62+
63+ REPO="${{ env.PRIME_REGISTRY }}/rancher/kube-webhook-certgen"
64+ skopeo inspect "docker://${REPO}:${KWC_TAG}" 1> /dev/null
65+ if [[ $? -eq 0 ]]; then
66+ echo "prime_exists=true" >> "$GITHUB_OUTPUT"
67+ else
68+ echo "prime_exists=false" >> "$GITHUB_OUTPUT"
69+ fi
70+
71+ - name : Login to Container Registry with Rancher Secrets
72+ if : github.repository_owner == 'rancher' && ( steps.certgen_exists.outputs.exists != 'true' || steps.prime_certgen_exists.outputs.prime_exists != 'true' )
73+ uses : docker/login-action@v3
74+ with :
75+ username : ${{ env.DOCKER_USERNAME }}
76+ password : ${{ env.DOCKER_TOKEN }}
77+
78+ # For forks, setup docker login with GHA secrets
79+ - name : Login to Container Registry
80+ if : github.repository_owner != 'rancher' && steps.certgen_exists.outputs.exists != 'true'
81+ uses : docker/login-action@v3
82+ with :
83+ username : ${{ secrets.DOCKER_USERNAME }}
84+ password : ${{ secrets.DOCKER_TOKEN }}
85+
86+ - name : Set up QEMU
87+ if : steps.certgen_exists.outputs.exists != 'true' || steps.prime_certgen_exists.outputs.prime_exists != 'true'
88+ uses : docker/setup-qemu-action@v3
89+
90+ - name : Set up Docker Buildx
91+ if : steps.certgen_exists.outputs.exists != 'true' || steps.prime_certgen_exists.outputs.prime_exists != 'true'
92+ uses : docker/setup-buildx-action@v3
93+
94+ - name : Setup Docker Credentials
95+ if : github.repository_owner != 'rancher' && steps.certgen_exists.outputs.exists != 'true'
96+ env :
97+ DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
98+ DOCKER_TOKEN : ${{ secrets.DOCKER_TOKEN }}
99+ run : |
100+ echo "DOCKER_USERNAME=$DOCKER_USERNAME" >> $GITHUB_ENV
101+ echo "DOCKER_TOKEN=$DOCKER_TOKEN" >> $GITHUB_ENV
102+
103+ - name : Build and push kube-webhook-certgen image
104+ if : steps.certgen_exists.outputs.exists != 'true' || steps.prime_certgen_exists.outputs.prime_exists != 'true'
105+ uses : rancher/ecm-distro-tools/actions/publish-image@9cc9d787c12b5ed1acdeb504e4ff59511ffd39c9 # v0.62.0
106+ with :
107+ image : kube-webhook-certgen
108+ tag : ${{ env.KWC_TAG }}
109+ make-target : push -C ./images/ NAME=kube-webhook-certgen
110+ public-repo : ${{ github.repository_owner }}
111+ public-username : ${{ env.DOCKER_USERNAME }}
112+ public-password : ${{ env.DOCKER_TOKEN }}
113+ push-to-public : ${{ steps.certgen_exists.outputs.exists != 'true' }}
114+
115+ prime-repo : rancher
116+ prime-registry : ${{ env.PRIME_REGISTRY }}
117+ prime-username : ${{ env.PRIME_REGISTRY_USERNAME }}
118+ prime-password : ${{ env.PRIME_REGISTRY_PASSWORD }}
119+ push-to-prime : ${{ github.repository_owner == 'rancher' && steps.prime_certgen_exists.outputs.prime_exists != 'true' }}
0 commit comments