-
Notifications
You must be signed in to change notification settings - Fork 440
add a workflow to check all images exist #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| name: Check Helm Chart Images | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| check-images: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install yq | ||
| run: | | ||
| sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | ||
| sudo chmod +x /usr/local/bin/yq | ||
|
|
||
| - name: Extract and validate images | ||
| run: | | ||
| set -e | ||
|
|
||
| VALUES_FILE="charts/temporal/values.yaml" | ||
| FAILED_IMAGES=() | ||
| declare -A SEEN_IMAGES | ||
|
|
||
| echo "Extracting images from $VALUES_FILE..." | ||
| echo "" | ||
|
|
||
| # Function to extract and check images | ||
| extract_images() { | ||
| local path_prefix="$1" | ||
|
|
||
| # Find all paths that have .image.repository or .image.repo | ||
| local repo_paths=$(yq eval ".. | select(has(\"image\")) | path | join(\".\")" "$VALUES_FILE" 2>/dev/null | sort -u || true) | ||
|
|
||
| while IFS= read -r path; do | ||
| if [ -z "$path" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| # Try to get repository (most common) | ||
| local repo=$(yq eval ".$path.image.repository" "$VALUES_FILE" 2>/dev/null) | ||
| local tag=$(yq eval ".$path.image.tag" "$VALUES_FILE" 2>/dev/null) | ||
|
|
||
| # If repository doesn't exist, try 'repo' (used by cassandra) | ||
| if [ "$repo" = "null" ] || [ -z "$repo" ]; then | ||
| repo=$(yq eval ".$path.image.repo" "$VALUES_FILE" 2>/dev/null) | ||
| fi | ||
|
|
||
| # If we found both repo and tag, add to list | ||
| if [ "$repo" != "null" ] && [ -n "$repo" ] && [ "$tag" != "null" ] && [ -n "$tag" ]; then | ||
| local full_image="$repo:$tag" | ||
| # Use associative array to avoid duplicates | ||
| if [ -z "${SEEN_IMAGES[$full_image]}" ]; then | ||
| SEEN_IMAGES[$full_image]=1 | ||
| fi | ||
| fi | ||
| done <<< "$repo_paths" | ||
| } | ||
|
|
||
| # Extract all images | ||
| extract_images | ||
|
|
||
| # Convert associative array to regular array | ||
| IMAGES=() | ||
| for img in "${!SEEN_IMAGES[@]}"; do | ||
| IMAGES+=("$img") | ||
| done | ||
|
|
||
| # Sort images for consistent output | ||
| IFS=$'\n' IMAGES=($(sort <<<"${IMAGES[*]}")) | ||
| unset IFS | ||
|
|
||
| if [ ${#IMAGES[@]} -eq 0 ]; then | ||
| echo "⚠ No images found in $VALUES_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Found ${#IMAGES[@]} image(s) to validate:" | ||
| for img in "${IMAGES[@]}"; do | ||
| echo " - $img" | ||
| done | ||
| echo "" | ||
|
|
||
| # Pull each image and track failures | ||
| for image in "${IMAGES[@]}"; do | ||
| echo "Pulling $image..." | ||
| if docker pull "$image"; then | ||
| echo "✓ Successfully pulled $image" | ||
| else | ||
| echo "✗ Failed to pull $image" | ||
| FAILED_IMAGES+=("$image") | ||
| fi | ||
| echo "" | ||
| done | ||
|
|
||
| # Report results | ||
| if [ ${#FAILED_IMAGES[@]} -eq 0 ]; then | ||
| echo "==========================================" | ||
| echo "SUCCESS: All ${#IMAGES[@]} image(s) are accessible!" | ||
| echo "==========================================" | ||
| exit 0 | ||
| else | ||
| echo "==========================================" | ||
| echo "FAILURE: ${#FAILED_IMAGES[@]} of ${#IMAGES[@]} image(s) could not be pulled:" | ||
| for img in "${FAILED_IMAGES[@]}"; do | ||
| echo " ✗ $img" | ||
| done | ||
| echo "==========================================" | ||
| exit 1 | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semgrep identified an issue in your code:
No explicit
GITHUB_TOKENpermissions found at the workflow or job level. Add apermissions:block at the workflow root (applies to all jobs) or per job with least privilege (e.g.,contents: readand only specific writes likepull-requests: writeif needed).To resolve this comment:
🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasonsAlternatively, triage in Semgrep AppSec Platform to ignore the finding created by missing-explicit-permissions.
You can view more details about this finding in the Semgrep AppSec Platform.