Skip to content

Commit

Permalink
Update Docker updater workflow (#2679)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lucacome authored Oct 11, 2024
1 parent fac76d7 commit 7644959
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
packages: write # for docker/build-push-action to push to GHCR
id-token: write # for docker/login to login to NGINX registry
runs-on: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') && 'kic-plus' || 'ubuntu-22.04' }}
runs-on: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') && 'kic-plus' || 'ubuntu-24.04' }}
services:
registry:
image: registry:2
Expand Down Expand Up @@ -101,6 +101,7 @@ jobs:
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
context: ${{ inputs.tag != '' && 'git' || 'workflow' }}
images: |
name=ghcr.io/nginxinc/nginx-gateway-fabric,enable=${{ inputs.image == 'ngf' && github.event_name != 'pull_request' }}
name=ghcr.io/nginxinc/nginx-gateway-fabric/nginx,enable=${{ inputs.image == 'nginx' && github.event_name != 'pull_request' }}
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/update-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ name: Update Docker Images
on:
schedule:
- cron: "0 2 * * *" # run every day at 02:00 UTC
workflow_dispatch: # yamllint disable-line rule:empty-values
workflow_dispatch:
inputs:
force-update:
description: 'Force update of images'
required: false
type: boolean

defaults:
run:
Expand Down Expand Up @@ -43,15 +48,15 @@ jobs:
- name: Set NGINX version
id: nginx
run: |
version=library/nginx:$(grep -m1 "FROM.*nginx:.*alpine" < build/Dockerfile.nginx | awk -F"[ :]" '{print $3}')
version=$(grep -m1 "FROM.*nginx:.*alpine" < build/Dockerfile.nginx | awk -F" " '{print $2}')
echo nginx_version=${version} >> $GITHUB_OUTPUT
check:
name: Check if updates are needed
runs-on: ubuntu-24.04
needs: variables
outputs:
needs-updating: ${{ steps.needs.outputs.needs-updating }}
needs-updating: ${{ steps.update.outputs.needs-updating }}
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
Expand All @@ -66,15 +71,11 @@ jobs:
with:
base-image: ${{ needs.variables.outputs.nginx_version }}
image: ghcr.io/nginxinc/nginx-gateway-fabric/nginx:${{ needs.variables.outputs.ngf_tag }}
platforms: "linux/arm64,linux/amd64"

- id: needs
run: echo "needs-updating=${{ steps.update.outputs.needs-updating }}" >> $GITHUB_OUTPUT

build:
name: Build Image
needs: [variables, check]
if: ${{ needs.check.outputs.needs-updating }}
if: ${{ needs.check.outputs.needs-updating == 'true' || inputs.force-update == true }}
uses: ./.github/workflows/build.yml
with:
image: nginx
Expand Down

0 comments on commit 7644959

Please sign in to comment.