mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-19 13:59:15 +02:00
Update weekly stats workflow to read YAML configs
This commit is contained in:
30
.github/workflows/weekly_stats.yaml
vendored
30
.github/workflows/weekly_stats.yaml
vendored
@@ -36,23 +36,41 @@ jobs:
|
|||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
for f in $( find -- * -maxdepth 0 -type d | sort -r ); do
|
for f in $( find -- * -maxdepth 0 -type d | sort -r ); do
|
||||||
DOWNLOADS=0
|
DOWNLOADS=0
|
||||||
if [ -f "$f"/config.json ] && jq -e '.image' "$f/config.json"; then
|
COUNT1="-"
|
||||||
SLUG="$(jq -r '.image' "$f/config.json" | awk -F 'alexbelgium/|-{arch' '{print $2}')"
|
COUNT2="-"
|
||||||
if [[ "$(jq '.arch[]' "$f/config.json")" == *"armv7"* ]]; then
|
COUNT3="-"
|
||||||
|
IMAGE=""
|
||||||
|
ARCHES=""
|
||||||
|
if [ -f "$f"/config.json ] && jq -e '.image' "$f/config.json" >/dev/null; then
|
||||||
|
IMAGE="$(jq -r '.image' "$f/config.json")"
|
||||||
|
ARCHES="$(jq -r '.arch[]?' "$f/config.json")"
|
||||||
|
elif [ -f "$f/config.yaml" ]; then
|
||||||
|
IMAGE="$(ruby -ryaml -e 'conf = YAML.load_file(ARGV[0]) rescue nil; img = conf && conf["image"]; exit 1 if img.nil? || img.to_s.empty?; puts img' "$f/config.yaml" 2>/dev/null || true)"
|
||||||
|
if [ -n "$IMAGE" ]; then
|
||||||
|
ARCHES="$(ruby -ryaml -e 'conf = YAML.load_file(ARGV[0]) rescue nil; Array(conf && conf["arch"]).compact.each { |a| puts a }' "$f/config.yaml" 2>/dev/null || true)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -n "$IMAGE" ]; then
|
||||||
|
SLUG="$(printf '%s\n' "$IMAGE" | awk -F 'alexbelgium/|-{arch' '{print $2}')"
|
||||||
|
else
|
||||||
|
SLUG=""
|
||||||
|
fi
|
||||||
|
if [ -n "$SLUG" ]; then
|
||||||
|
if printf '%s\n' "$ARCHES" | grep -qx 'armv7'; then
|
||||||
ARCH=armv7 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
|
ARCH=armv7 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
|
||||||
until [ -n "$COUNT" ]; do COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')" && sleep 5; ((c++)) && echo "repeat $c" && if [[ "$c" == 10 ]]; then COUNT=0; fi; done
|
until [ -n "$COUNT" ]; do COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')" && sleep 5; ((c++)) && echo "repeat $c" && if [[ "$c" == 10 ]]; then COUNT=0; fi; done
|
||||||
COUNT="${COUNT//,/}"
|
COUNT="${COUNT//,/}"
|
||||||
COUNT1="$COUNT"
|
COUNT1="$COUNT"
|
||||||
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
|
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
|
||||||
else COUNT1="-"; fi
|
else COUNT1="-"; fi
|
||||||
if [[ "$(jq '.arch[]' "$f/config.json")" == *"amd64"* ]]; then
|
if printf '%s\n' "$ARCHES" | grep -qx 'amd64'; then
|
||||||
ARCH=amd64 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
|
ARCH=amd64 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
|
||||||
until [ -n "$COUNT" ]; do COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')" && sleep 5; ((c++)) && echo "repeat $c" && if [[ "$c" == 10 ]]; then COUNT=0; fi; done
|
until [ -n "$COUNT" ]; do COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')" && sleep 5; ((c++)) && echo "repeat $c" && if [[ "$c" == 10 ]]; then COUNT=0; fi; done
|
||||||
COUNT="${COUNT//,/}"
|
COUNT="${COUNT//,/}"
|
||||||
COUNT2="$COUNT"
|
COUNT2="$COUNT"
|
||||||
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
|
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
|
||||||
else COUNT2="-"; fi
|
else COUNT2="-"; fi
|
||||||
if [[ "$(jq '.arch[]' "$f/config.json")" == *"aarch64"* ]]; then
|
if printf '%s\n' "$ARCHES" | grep -qx 'aarch64'; then
|
||||||
ARCH=aarch64 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
|
ARCH=aarch64 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
|
||||||
until [ -n "$COUNT" ]; do COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')" && sleep 5; ((c++)) && echo "repeat $c" && if [[ "$c" == 10 ]]; then COUNT=0; fi; done
|
until [ -n "$COUNT" ]; do COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')" && sleep 5; ((c++)) && echo "repeat $c" && if [[ "$c" == 10 ]]; then COUNT=0; fi; done
|
||||||
COUNT="${COUNT//,/}"
|
COUNT="${COUNT//,/}"
|
||||||
@@ -71,6 +89,8 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
# Add data
|
# Add data
|
||||||
sed -i "/${SLUG}$/s|^-|$DOWNLOADS|" "$file"
|
sed -i "/${SLUG}$/s|^-|$DOWNLOADS|" "$file"
|
||||||
|
else
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user