|
72 | 72 | sed -i -e "s/^\(\s*ImageDigest\s*=\s*\)\".*\"/\1\"$redisImageDigest\"/" install/installer/pkg/components/redis/constants.go |
73 | 73 | sed -i -e "s/^\(\s*ExporterImageDigest\s*=\s*\)\".*\"/\1\"$redisExporterDigest\"/" install/installer/pkg/components/redis/constants.go |
74 | 74 | go fmt install/installer/pkg/components/redis/constants.go |
| 75 | + - name: Update base image tags in Dockerfiles |
| 76 | + shell: bash |
| 77 | + run: | |
| 78 | + # Updates FROM lines in Dockerfiles that use tag-based references (not @sha256: pinned). |
| 79 | + # For each tracked image, finds the latest patch release matching the same major.minor |
| 80 | + # prefix and suffix, then updates all Dockerfiles that reference an older version. |
| 81 | + # |
| 82 | + # Entry format: "image|tag_grep_in_dockerfile|tag_ls_filter" |
| 83 | + # - image: the registry image name (e.g. "node", "caddy/caddy") |
| 84 | + # - tag_grep_in_dockerfile: grep -oP regex to extract the current tag from FROM lines |
| 85 | + # - tag_ls_filter: grep -E regex to filter crane ls output for candidate tags |
| 86 | +
|
| 87 | + declare -a TRACKED_IMAGES=( |
| 88 | + "node|22\\.22\\.[0-9]+-alpine|^22\\.22\\.[0-9]+-alpine$" |
| 89 | + "node|22\\.22\\.[0-9]+$|^22\\.22\\.[0-9]+$" |
| 90 | + "caddy/caddy|2\\.11[0-9.]*-alpine|^2\\.11(\\.[0-9]+)?-alpine$" |
| 91 | + ) |
| 92 | +
|
| 93 | + for entry in "${TRACKED_IMAGES[@]}"; do |
| 94 | + IFS='|' read -r image tag_grep tag_ls_filter <<< "$entry" |
| 95 | + echo "Checking for updates: ${image} (filter: ${tag_ls_filter})" |
| 96 | +
|
| 97 | + # List all tags matching the pattern and pick the highest version |
| 98 | + latest_tag=$(crane ls "$image" 2>/dev/null \ |
| 99 | + | grep -E "$tag_ls_filter" \ |
| 100 | + | sort -V \ |
| 101 | + | tail -1 || true) |
| 102 | +
|
| 103 | + if [ -z "$latest_tag" ]; then |
| 104 | + echo " No matching tags found, skipping" |
| 105 | + continue |
| 106 | + fi |
| 107 | +
|
| 108 | + echo " Latest tag: ${image}:${latest_tag}" |
| 109 | +
|
| 110 | + # Escape slashes in image name for use in grep/sed |
| 111 | + image_escaped="${image//\//\\/}" |
| 112 | +
|
| 113 | + # Find and update Dockerfiles with older versions of this image |
| 114 | + while IFS= read -r -d '' file; do |
| 115 | + current=$(grep -oP "(?<=FROM ${image_escaped}:)${tag_grep}" "$file" 2>/dev/null | head -1 || true) |
| 116 | + if [ -n "$current" ] && [ "$current" != "$latest_tag" ]; then |
| 117 | + echo " Updating ${file}: ${image}:${current} -> ${image}:${latest_tag}" |
| 118 | + sed -i "s|FROM ${image}:${current}|FROM ${image}:${latest_tag}|g" "$file" |
| 119 | + fi |
| 120 | + done < <(find "$(pwd)/components" -type f \( -name "Dockerfile*" -o -name "leeway.Dockerfile" \) -print0) |
| 121 | + done |
| 122 | +
|
75 | 123 | - name: Check workspace |
76 | 124 | id: create_pr |
77 | 125 | shell: bash |
|
0 commit comments