Skip to content

Commit

Permalink
feat: ci script to check if images all images have registry set
Browse files Browse the repository at this point in the history
  • Loading branch information
ed382 committed Oct 24, 2024
1 parent 6195431 commit 0b9daf4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/lint-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint images

on:
push:
branches:
- main
pull_request:

jobs:
lint-images:
name: Lint images
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run image check script
run: bash scripts/image_check.sh
28 changes: 28 additions & 0 deletions scripts/image_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

REPO=myownrepo.com/prefix
AGENT_IMAGES=images.txt

# Get images for the agent chart
helm template test ../charts/testkube --skip-crds --set global.imageRegistry="$REPO" --set mongodb.enabled=false --set testkube-api.minio.enabled=false --set testkube-dashboard.enabled=false --set global.testWorkflows.createOfficialTemplates=false | grep "image:" | grep -v "{" | sed 's/"//g' | sed 's/docker.io\///g' | awk '{ print $2 }' | awk 'NF && !seen[$0]++' | sort > "$AGENT_IMAGES"

# Get the images for the workflows
helm template test ../charts/testkube --skip-crds --set global.imageRegistry="$REPO" --set mongodb.enabled=false --set testkube-api.minio.enabled=false --set testkube-dashboard.enabled=false --set global.testWorkflows.createOfficialTemplates=false | grep "testkube-tw" | sed 's/"//g' | sed 's/docker.io\///g' | awk '{ print $2 }' | awk 'NF && !seen[$0]++' | sort >> "$AGENT_IMAGES"

# Sort these agent images
sort -o "$AGENT_IMAGES" "$AGENT_IMAGES"

# Check for images that do not start with the image registry
failure=false
while IFS= read -r line; do
if [[ ! "$line" =~ ^"$REPO" ]]; then
echo "Failure: Line '$line' does not start with '$REPO'."
failure=true
fi
done < "$AGENT_IMAGES"

if [ "$failure" = true ]; then
exit 1
fi

echo "All lines start with '$REPO'."

0 comments on commit 0b9daf4

Please sign in to comment.