Skip to content

Commit 2511c3f

Browse files
committed
Update Docker updater workflow (nginx#2679)
Fixed a few issues in the workflow, mainly the build step that had a wrong if (all the outputs are strings). Also added an option to force the update.
1 parent 029b59c commit 2511c3f

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
2828
packages: write # for docker/build-push-action to push to GHCR
2929
id-token: write # for docker/login to login to NGINX registry
30-
runs-on: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') && 'kic-plus' || 'ubuntu-22.04' }}
30+
runs-on: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') && 'kic-plus' || 'ubuntu-24.04' }}
3131
services:
3232
registry:
3333
image: registry:2
@@ -101,6 +101,7 @@ jobs:
101101
id: meta
102102
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
103103
with:
104+
context: ${{ inputs.tag != '' && 'git' || 'workflow' }}
104105
images: |
105106
name=ghcr.io/nginxinc/nginx-gateway-fabric,enable=${{ inputs.image == 'ngf' && github.event_name != 'pull_request' }}
106107
name=ghcr.io/nginxinc/nginx-gateway-fabric/nginx,enable=${{ inputs.image == 'nginx' && github.event_name != 'pull_request' }}

.github/workflows/update-docker-images.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name: Update Docker Images
33
on:
44
schedule:
55
- cron: "0 2 * * *" # run every day at 02:00 UTC
6-
workflow_dispatch: # yamllint disable-line rule:empty-values
6+
workflow_dispatch:
7+
inputs:
8+
force-update:
9+
description: 'Force update of images'
10+
required: false
11+
type: boolean
712

813
defaults:
914
run:
@@ -43,15 +48,15 @@ jobs:
4348
- name: Set NGINX version
4449
id: nginx
4550
run: |
46-
version=library/nginx:$(grep -m1 "FROM.*nginx:.*alpine" < build/Dockerfile.nginx | awk -F"[ :]" '{print $3}')
51+
version=$(grep -m1 "FROM.*nginx:.*alpine" < build/Dockerfile.nginx | awk -F" " '{print $2}')
4752
echo nginx_version=${version} >> $GITHUB_OUTPUT
4853
4954
check:
5055
name: Check if updates are needed
5156
runs-on: ubuntu-24.04
5257
needs: variables
5358
outputs:
54-
needs-updating: ${{ steps.needs.outputs.needs-updating }}
59+
needs-updating: ${{ steps.update.outputs.needs-updating }}
5560
steps:
5661
- name: Login to GitHub Container Registry
5762
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
@@ -66,15 +71,11 @@ jobs:
6671
with:
6772
base-image: ${{ needs.variables.outputs.nginx_version }}
6873
image: ghcr.io/nginxinc/nginx-gateway-fabric/nginx:${{ needs.variables.outputs.ngf_tag }}
69-
platforms: "linux/arm64,linux/amd64"
70-
71-
- id: needs
72-
run: echo "needs-updating=${{ steps.update.outputs.needs-updating }}" >> $GITHUB_OUTPUT
7374

7475
build:
7576
name: Build Image
7677
needs: [variables, check]
77-
if: ${{ needs.check.outputs.needs-updating }}
78+
if: ${{ needs.check.outputs.needs-updating == 'true' || inputs.force-update == true }}
7879
uses: ./.github/workflows/build.yml
7980
with:
8081
image: nginx

0 commit comments

Comments
 (0)