Skip to content

Commit

Permalink
Checking multiarchitecture of iamges
Browse files Browse the repository at this point in the history
  • Loading branch information
YashasviDevtron committed Jun 4, 2024
1 parent 4e39be6 commit 83e8d18
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/multiarch_new (1).yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Multi-Arch Image Check

on:
pull_request:
types: [closed]

jobs:
check-multiarch:
name: Check Multi-Arch Images
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && github.event.pull_request.head.ref == 'release-bot'
runs-on: ubuntu-latest

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Install yq
run: |
sudo apt-get update && sudo apt-get install -y jq
sudo apt-get install -y python3-pip
sudo pip3 install yq
- name: Authenticate with GitHub
run: echo "${{ secrets.token }}" | gh auth login --with-token

- name: Check Multi-Arch Images
env:
GITHUB_TOKEN: ${{ secrets.token }}
PRNUM: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
yq '.' charts/devtron/values.yaml > values.json
get_image_arch() {
local image="$1"
local image_ref=$(echo $image | sed 's/:.*//')
if [[ "$image_ref" == "inception" || "$image_ref" == "postgres" || "$image_ref" == "postgres_exporter" || "$image_ref" == "workflow-controller" ]]; then
return
fi
local arch=$(docker manifest inspect "quay.io/devtron/$image" | jq -r '.manifests[].platform.architecture' | sort | uniq)
if [ $? -ne 0 ]; then
error_images+=("$image")
return
fi
if ! (echo "$arch" | grep -q "amd64" && (echo "$arch" | grep -q "arm64" || echo "$arch" | grep -q "arm")); then
echo "$image Image does not support multiarchitecture"
non_multiarch_images+=("$image")
else
echo "$image supports multi-architecture: $arch"
fi
}
while read -r line; do
image=$(echo "$line" | cut -d'"' -f4)
if [ -n "$image" ]; then
echo "$image"
get_image_arch "$image"
fi
done < <(grep -Eo '"image":\s*"[^"]*"' values.json)
if [ ${#non_multiarch_images[@]} -ne 0 ]; then
echo "The following images do not support multi-architecture:"
printf '%s\n' "${non_multiarch_images[@]}"
gh pr edit $PRNUM --add-label "PR:Issue-verification-failed"
gh pr edit $PRNUM --remove-label "PR:Ready-to-Review"
exit 1
else
echo "All images support multi-architecture."
echo "PR:Ready-to-Review, exiting gracefully"
gh pr edit $PRNUM --add-label "PR:Ready-to-Review"
gh pr edit $PRNUM --remove-label "PR:Issue-verification-failed"
exit 0
fi

0 comments on commit 83e8d18

Please sign in to comment.