Update daily_README.yaml

This commit is contained in:
Alexandre
2022-12-04 06:46:03 +01:00
committed by GitHub
parent 885f47130f
commit 1a20d11221

View File

@@ -15,10 +15,6 @@ jobs:
run: |
# Init
echo "Starting"
declare -i DOWNLOADS
declare -i COUNT
rm Stats
# Go through all folders, add to filters if not existing
for f in $( find -- * -maxdepth 0 -type d | sort -r ); do
@@ -42,12 +38,64 @@ jobs:
# Sort yaml
sort -t= ".github/paths-filter.yml" -o ".github/paths-filter.yml"
- name: Create stats
rm Stats
echo "Starting"
COUNT=0
COUNT1=0
COUNT2=0
COUNT3=0
# Go through all folders, add to filters if not existing
for f in $( find -- * -maxdepth 0 -type d | sort -r ); do
if [ -f "$f"/config.json ]; then
if [[ $(jq '.arch[]' "$f/config.json") == *"armv7"* ]]; then
ARCH=armv7 && COUNT="$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
if [ -z "$COUNT" ]; then echo "$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}')"; fi
COUNT1="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"; fi
if [[ $(jq '.arch[]' "$f/config.json") == *"amd64"* ]]; then
ARCH=amd64 && COUNT="$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
until [ ! -z "$COUNT" ]; do COUNT="$(curl -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; done
COUNT2="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"; fi
if [[ $(jq '.arch[]' "$f/config.json") == *"aarch64"* ]]; then
ARCH=aarch64 && COUNT="$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
if [ -z "$COUNT" ]; then echo "$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}')"; fi
COUNT3="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))";fi
echo "$SLUG $DOWNLOADS $COUNT1 $COUNT2 $COUNT3" >> Stats
fi
done
# Make stats
echo "1"
sort -k2,2 -n Stats > tmp && mv tmp Stats
echo "2"
sed -i "1i Name Total armv7 amd64 aarch64" Stats
echo "3"
TOTAL="$(awk '{SUM+=$2}END{print SUM}' Stats)"
TOTAL1="$(awk '{SUM+=$2}END{print SUM}' Stats)"
TOTAL2="$(awk '{SUM+=$2}END{print SUM}' Stats)"
TOTAL3="$(awk '{SUM+=$2}END{print SUM}' Stats)"
echo "4"
# Make plot
#apt-get install gnuplot -y
#https://www.xmodulo.com/draw-stacked-histogram-gnuplot.html
# Sort yaml
sort -t= ".github/paths-filter.yml" -o ".github/paths-filter.yml"
- name: Create README file
run: >
# Init
echo "Starting"
declare -i DOWNLOADS
declare -i COUNT
# Prepare template
@@ -57,7 +105,6 @@ jobs:
sed -i "/**ADDONS_LIST%%/d" README2.md
# Sort folders by addon name
for f in $( find -- * -maxdepth 0 -type d | sort -r ); do
@@ -84,11 +131,6 @@ jobs:
NAME=$(jq -r '.name' "$f/config.json")
DESCRIPTION=$(jq -r '.description' "$f/config.json")
SLUG=$(jq -r '.image' "$f/config.json" | awk -F 'alexbelgium/|-{arch' '{print $2}')
DOWNLOADS=0
COUNT=0
COUNT1=0
COUNT2=0
COUNT3=0
# Get icon
if [ "$(jq '.panel_icon' "$f/config.json")" != null ]; then
ICON="$(jq -r '.panel_icon' "$f/config.json")"
@@ -109,50 +151,19 @@ jobs:
if [[ $(jq '.ingress' "$f/config.json" 2>/dev/null) == "true" ]]; then sed -i "$ADDONSLINE"'a ![ingress][ingress-badge]' README2.md; fi
if [[ $(jq '.arch[]' "$f/config.json") == *"armv7"* ]]; then
sed -i "$ADDONSLINE"'a ![armv7][armv7-badge]' README2.md
ARCH=armv7 && COUNT="$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
if [ -z "$COUNT" ]; then echo "$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}')"; fi
COUNT1="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
else sed -i "$ADDONSLINE"'a ![armv7no][armv7no-badge]' README2.md; fi || true
if [[ $(jq '.arch[]' "$f/config.json") == *"amd64"* ]]; then
sed -i "$ADDONSLINE"'a ![amd64][amd64-badge]' README2.md
ARCH=amd64 && COUNT="$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
until [ ! -z "$COUNT" ]; do COUNT="$(curl -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; done
COUNT2="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
else sed -i "$ADDONSLINE"'a ![amd64no][amd64no-badge]' README2.md; fi || true
if [[ $(jq '.arch[]' "$f/config.json") == *"aarch64"* ]]; then
sed -i "$ADDONSLINE"'a ![aarch64][aarch64-badge]' README2.md
ARCH=aarch64 && COUNT="$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}' | awk -F '<|>' '{print $3}')"
if [ -z "$COUNT" ]; then echo "$(curl -f -s -L https://github.com/alexbelgium/hassio-addons/pkgs/container/$SLUG-$ARCH/latest | awk '/Total downloads/{getline; print}')"; fi
COUNT3="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
else sed -i "$ADDONSLINE"'a ![aarch64no][aarch64no-badge]' README2.md; fi || true
if [[ -f "$f/updater.json" ]]; then sed -i "$ADDONSLINE"'a ![Update](https://img.shields.io/badge/dynamic/json?label=Updated&query=%24.last_update&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2F'"$FOLDERNAME"'%2Fupdater.json)' README2.md; fi
sed -i "$ADDONSLINE"'a &emsp;&emsp;![Version](https://img.shields.io/badge/dynamic/json?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2F'"$FOLDERNAME"'%2Fconfig.json)' README2.md || true
sed -i "$ADDONSLINE"'a &#10003; '"$ICON"' ['"$NAME"']('"$FOLDERNAME"'/) : '"$DESCRIPTION\\n" README2.md
echo "$SLUG $DOWNLOADS $COUNT1 $COUNT2 $COUNT3" >> Stats
fi
done
# Make stats
echo "1"
sort -k2,2 -n Stats > tmp && mv tmp Stats
echo "2"
sed -i "1i Name Total armv7 amd64 aarch64" Stats
echo "3"
TOTAL="$(awk '{SUM+=$2}END{print SUM}' Stats)"
TOTAL1="$(awk '{SUM+=$2}END{print SUM}' Stats)"
TOTAL2="$(awk '{SUM+=$2}END{print SUM}' Stats)"
TOTAL3="$(awk '{SUM+=$2}END{print SUM}' Stats)"
echo "4"
# Make plot
#apt-get install gnuplot -y
#https://www.xmodulo.com/draw-stacked-histogram-gnuplot.html
# Restore folders name
echo "Restore structure"