Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Update versions.md

on:
push:
branches:
- main

jobs:
update_versions:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: setup-helmfile
uses: mamezou-tech/[email protected]
with:
install-helm-plugins: no
install-kubectl: no

- name: Update versions.md
run: bin/version_scan

- name: Commit and push if versions.md changed
run: |
git diff
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git commit -am "Update versions.md" || exit 0
git push
72 changes: 72 additions & 0 deletions bin/version_scan
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

cd "$(dirname "${BASH_SOURCE[0]}")/.."

# Initialize a RADAR-base deployment where all components are installed.
yes | ./bin/init
sed -i '/_install: /s/false/true/' etc/production.yaml

helmfile template | grep -E "helm.sh/chart:|image:|containers:|initContainers:" | uniq | sed -r "s/\s+//g" | sed "s/\"//g" | sed -r "s/^-//g" > /tmp/helmfile.txt

declare -A container
declare -A init

for line in $(cat /tmp/helmfile.txt); do
if [[ $line == *"chart:"* ]]; then
chart=$(echo $line | sed -r "s/helm.*chart://g")
elif [[ $line == *"containers:"* ]]; then
containerType=container
elif [[ $line == *"initContainers:"* ]]; then
containerType=init
elif [[ $line == *"image:"* ]]; then
image=$(echo $line | sed "s/image://g")
if [ $containerType == "container" ]; then
if [ -z "${container[$image]}" ]; then
container[$image]=$chart
else
container[$image]=${container[$image]},$chart
fi
elif [ -z "${init[$image]}" ]; then
init[$image]=$chart
else
init[$image]=${init[$image]},$chart
fi
fi
done

touch versions.md
echo "# Versions" > versions.md
echo >> versions.md
echo " This file is automatically generated (by the [version_scan](bin/version_scan) script). Do not edit manually." >> versions.md
echo >> versions.md

echo "## Helm Charts" >> versions.md
echo "| Chart | Version |" >> versions.md
echo "| :----- | :----- |" >> versions.md
charts=$(echo ${container[@]} | tr "," " " | tr " " "\n" | sort -u)
for chart in $charts; do
chartName=${chart%-*}
chartVersion=${chart##*-}
echo "| $chartName | $chartVersion |" >> versions.md
done

echo >> versions.md

echo "## Containers" >> versions.md
echo "| Image | Helm Charts |" >> versions.md
echo "| :----- | :----- |" >> versions.md
images=$(echo ${!container[@]} | tr " " "\n" | sort -u)
for key in $images; do
charts=$(echo ${container[$key]} | tr "," "\n" | sort -u | tr "\n" "," | sed "s/,/<br>/g" | sed "s/<br>$//g")
echo "| $key | $charts |" >> versions.md
done

echo >> versions.md

echo "## Init Containers" >> versions.md
echo "| Image | Helm Charts |" >> versions.md
echo "| :----- | :----- |" >> versions.md
for key in "${!init[@]}"; do
charts=$(echo ${init[$key]} | tr "," "\n" | sort -u | tr "\n" "," | sed "s/,/<br>/g" | sed "s/<br>$//g")
echo "| $key | $charts |" >> versions.md
done