Skip to content

Commit edfffdc

Browse files
committed
automatically detect Dockerfiles that need updates
1 parent 0796542 commit edfffdc

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ To bump the Go version across all Docker images in this repository, use the auto
2525

2626
1. Validates the target Go version format
2727
2. Fetches the SHA256 checksum for `go<version>.linux-amd64.tar.gz` from https://go.dev/dl/
28-
3. Updates `GOLANG_VERSION` and `GOLANG_SHA256` in all relevant Dockerfiles:
29-
- `images/stackrox-build.Dockerfile`
30-
- `images/stackrox-ui-test.Dockerfile`
31-
- `images/scanner-build.Dockerfile`
32-
4. Creates a new branch named `bump-go-<version>`
33-
5. Commits the changes with a descriptive message
34-
6. Pushes the branch to origin
35-
7. Creates a pull request (requires [GitHub CLI](https://cli.github.com/))
28+
3. Automatically finds all Dockerfiles containing `GOLANG_VERSION` argument
29+
4. Updates `GOLANG_VERSION` and `GOLANG_SHA256` in all found Dockerfiles
30+
5. Creates a new branch named `bump-go-<version>`
31+
6. Commits the changes with a descriptive message
32+
7. Pushes the branch to origin
33+
8. Creates a pull request (requires [GitHub CLI](https://cli.github.com/))
3634

3735
### Requirements
3836

@@ -41,4 +39,3 @@ To bump the Go version across all Docker images in this repository, use the auto
4139
- (Optional) [GitHub CLI](https://cli.github.com/) for automatic PR creation
4240

4341
If GitHub CLI is not installed, the script will provide a link to manually create the PR.
44-

scripts/bump_go_version.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,19 @@ fi
6969

7070
info "Found SHA256: $SHA256"
7171

72-
# Files to update
73-
DOCKERFILES=(
74-
"images/stackrox-build.Dockerfile"
75-
"images/stackrox-ui-test.Dockerfile"
76-
"images/scanner-build.Dockerfile"
77-
)
72+
# Find all Dockerfiles that contain GOLANG_VERSION
73+
info "Finding Dockerfiles with GOLANG_VERSION..."
74+
mapfile -t DOCKERFILES < <(grep -rl "ARG GOLANG_VERSION=" images/ 2>/dev/null | sort)
75+
76+
if [ ${#DOCKERFILES[@]} -eq 0 ]; then
77+
error "No Dockerfiles found with GOLANG_VERSION argument"
78+
exit 1
79+
fi
80+
81+
info "Found ${#DOCKERFILES[@]} Dockerfile(s) to update:"
82+
for dockerfile in "${DOCKERFILES[@]}"; do
83+
info " - $dockerfile"
84+
done
7885

7986
# Update each Dockerfile
8087
info "Updating Dockerfiles..."
@@ -158,7 +165,7 @@ PR_BODY="This PR updates the Go version to ${TARGET_VERSION} across all Docker i
158165
- Source: https://go.dev/dl/
159166
160167
## Affected Files
161-
$(for dockerfile in "${DOCKERFILES[@]}"; do echo "- \`$dockerfile\`"; done)"
168+
$(printf '%s\n' "${DOCKERFILES[@]}" | sed 's/^/- `/' | sed 's/$/`/')"
162169

163170
if command -v gh &> /dev/null; then
164171
PR_URL=$(gh pr create --title "$PR_TITLE" --body "$PR_BODY" --web 2>&1 | tee /dev/tty | grep -o 'https://github.com/[^[:space:]]*' || true)

0 commit comments

Comments
 (0)