This commit is contained in:
2024-06-17 17:34:06 +02:00
parent da23315ab9
commit 97b4e2d7b1
409 changed files with 4274 additions and 15396 deletions

View File

@@ -0,0 +1,65 @@
---
name: Lint / Syntax checks
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
hadolint:
runs-on: ubuntu-latest
container: ghcr.io/hadolint/hadolint:latest-alpine
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: Get changed files
id: changed_files
uses: jitterbit/get-changed-files@v1
- name: 🔎 Run hadolint
run: |
# shellcheck disable=SC2043
for files in ${{ steps.changed_files.outputs.all }}; do
if [[ "$(basename ${files})" == "Dockerfile" ]]; then
echo "Hadolint $files"
hadolint "$files"
fi
done
shellcheck:
runs-on: ubuntu-latest
container: koalaman/shellcheck-alpine:latest
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: Get changed files
id: changed_files
uses: jitterbit/get-changed-files@v1
- name: 🔎 Run ShellCheck
run: |
# shellcheck disable=SC2043
for files in ${{ steps.changed_files.outputs.all }}; do
if [[ "$files" == *".sh" ]]; then
echo "Spellcheck $files"
shellcheck "$files"
fi
done
markdownlint:
runs-on: ubuntu-latest
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: 🔎 Run markdownlint
uses: nosborn/github-action-markdown-cli@v3.3.0
with:
config_file: .markdownlint.yaml

157
.github/workflows/daily_README.yaml vendored Normal file
View File

@@ -0,0 +1,157 @@
# yamllint disable rule:line-length
---
name: Generate README
on:
schedule:
- cron: 0 17 * * *
workflow_dispatch: null
jobs:
README_updater:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Create README file
run: |
# Init
echo "Starting"
# Prepare template
cp .templates/.README.md README2.md
ADDONSLINE="$(sed -n '/%%ADDONS_LIST%%/=' README2.md)"
sed -i "/**ADDONS_LIST%%/d" README2.md
# Sort folders by addon name
# shellcheck disable=SC2086
for f in $( find -- * -maxdepth 0 -type d | sort -r ); do
if [ -f "$f"/config.json ]; then
NAME=$(jq -r '.name' "$f"/config.json)
if [[ "$f" != "$NAME" ]]; then
echo "$f" > "$f"/oldname
mv "$f" "$NAME"
fi
fi
done
# Populate template
find -- * -maxdepth 0 -type d | sort -r | while read -r f; do
# $f is an addon directory
if [ -f "$f/config.json" ]; then
echo "Project $f"
# Get variables
if [ -f "$f/oldname" ]; then FOLDERNAME="$(cat "$f/oldname")"; else FOLDERNAME="$f"; fi
NAME="$(jq -r '.name' "$f/config.json")"
DESCRIPTION="$(jq -r '.description' "$f/config.json")"
# Get icon
if [ "$(jq '.panel_icon' "$f/config.json")" != null ]; then
ICON="$(jq -r '.panel_icon' "$f/config.json")"
ICON="${ICON#*:}"
ICON="![image](https://api.iconify.design/mdi/$ICON.svg)"
else
ICON=""
fi
# Write infos
echo "Writing infos"
sed -i "$ADDONSLINE"'{G;}' README2.md
if [[ "$(jq '.schema' "$f/config.json" 2>/dev/null)" == *"localdisks"* ]]; then sed -i "$ADDONSLINE"'a ![localdisks][localdisks-badge]' README2.md; fi
if [[ "$(jq '.schema' "$f/config.json" 2>/dev/null)" == *"networkdisks"* ]]; then sed -i "$ADDONSLINE"'a ![smb][smb-badge]' README2.md; fi
if [[ "$(jq '.full_access' "$f/config.json" 2>/dev/null)" == "true" ]]; then sed -i "$ADDONSLINE"'a ![full_access][full_access-badge]' README2.md; fi
if [[ "$(jq '.services[]' "$f/config.json" 2>/dev/null)" == *"mqtt"* ]]; then sed -i "$ADDONSLINE"'a ![mqtt][mqtt-badge]' README2.md; fi
if [[ "$(jq '.services[]' "$f/config.json" 2>/dev/null)" == *"mysql"* ]]; then sed -i "$ADDONSLINE"'a ![MariaDB][mariadb-badge]' README2.md; fi
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
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
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
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   ![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 ✓ '"$ICON"' ['"$NAME"']('"$FOLDERNAME"'/) : '"$DESCRIPTION\\n" README2.md
fi
done
# Restore folders name
echo "Restore structure..."
find -- * -maxdepth 0 -type d | sort -r | while read -r f; do
if [ -f "$f/oldname" ]; then
NAME="$(cat "$f/oldname")"
rm "$f/oldname"
mv "$f" "$NAME"
fi
done
echo "... done"
# Write stats
# shellcheck disable=SC2002
echo "Global stats..."
STATS_DOWNLOADS="$(awk 'NR==2{print $1}' Stats)"
sed -i "s|%%STATS_DOWNLOADS%%|$STATS_DOWNLOADS|g" README2.md && \
sed -i "s|%%STATS_ADDONS%%|$(find . -name "config.json" | wc -l)|g" README2.md && \
STATS_ONE="$(awk 'NR==3{print $(NF)}' Stats)" && \
STATS_TWO="$(awk 'NR==4{print $(NF)}' Stats)" && \
STATS_THREE="$(awk 'NR==5{print $(NF)}' Stats)"
echo "Best addon is $STATS_ONE"
sed -i "s|%%STATS_ONE%%|${STATS_ONE^}|g" README2.md
sed -i "s|%%STATS_TWO%%|${STATS_TWO^}|g" README2.md
sed -i "s|%%STATS_THREE%%|${STATS_THREE^}|g" README2.md
echo "... done"
# Breakdown per arch
echo "Breakdown per arch..."
STATS_ARMV7="$(awk '{SUM+=$3}END{print SUM}' Stats2)"
STATS_AMD64="$(awk '{SUM+=$4}END{print SUM}' Stats2)"
STATS_AARCH64="$(awk '{SUM+=$5}END{print SUM}' Stats2)"
STATS_DOWNLOADS="$(( "$STATS_ARMV7" + "$STATS_AMD64" + "$STATS_AARCH64" ))"
STATS_ARMV7="$(awk -v t1="$STATS_ARMV7" -v t2="$STATS_AMD64" -v t3="$STATS_AARCH64" -v t4="$STATS_DOWNLOADS" 'BEGIN{printf "%.0f", t1/t4 * 100}')"
STATS_AMD64="$(awk -v t1="$STATS_ARMV7" -v t2="$STATS_AMD64" -v t3="$STATS_AARCH64" -v t4="$STATS_DOWNLOADS" 'BEGIN{printf "%.0f", t2/t4 * 100}')"
STATS_AARCH64="$(awk -v t1="$STATS_ARMV7" -v t2="$STATS_AMD64" -v t3="$STATS_AARCH64" -v t4="$STATS_DOWNLOADS" 'BEGIN{printf "%.0f", t3/t4 * 100}')"
sed -i "s|%%STATS_ARMV7%%|armv7: ${STATS_ARMV7}%|g" README2.md
sed -i "s|%%STATS_AMD64%%|amd64: ${STATS_AMD64}%|g" README2.md
sed -i "s|%%STATS_AARCH64%%|aarch64: ${STATS_AARCH64}%|g" README2.md
#echo $((100*$STATS_THREE/($STATS_ONE+$STATS_TWO+$STATS_THREE)))
echo "... done"
for var in "$STATS_ONE" "$STATS_TWO" "$STATS_THREE"; do
i=0
j=0
k=0
# shellcheck disable=SC2013
for i in $(sed -n "/$var/p" Stats); do
k="$((k+1))"
if [ "$k" -eq 3 ]; then break; fi
if [ "$i" -eq "$i" ] && [ "$i" -gt "$j" ]; then j="$i"; fi
done
sed -i "s|${var^}|${var^} (${j}x)|g" README2.md
echo "$STATS_ONE has $j downloads"
done
echo "... done"
# Replace template if change
echo "Replace template..."
mv README2.md README.md
echo "... done"
shell: bash
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
message: "GitHub bot : README updated"
default_author: github_actions

33
.github/workflows/daily_stale.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
# This workflow warns and then closes issues and PRs
# that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
---
name: Mark stale issues and pull requests
on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'stale'
stale-pr-label: 'stale'
days-before-stale: '5'
days-before-close: '2'
exempt-issue-labels: 'prevent stale'
remove-stale-when-updated: true

View File

@@ -0,0 +1,242 @@
# yamllint disable rule:line-length
---
name: Generate weekly graphs
on:
workflow_call:
workflow_dispatch:
jobs:
stats_graphs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install apps
run: |
git pull --rebase origin master
sudo apt-get update
sudo apt-get install gnuplot -y || true
- name: Create addons stats
run: |
# Prepare data
cp Stats Stats3
# Remove Totals
sed -i "2d" Stats3
# Inverse file
gawk -i inplace '{for(i=NF;i>1;i--)printf "%s ",$i;printf "%s",$1;print ""}' Stats3
# Only top 10
head -n 11 Stats3 > tmp_file && mv tmp_file Stats3
# Transpose data
awk '
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
}
}' Stats3 > StatsTmp && mv StatsTmp .github/Stats3
cd .github || true
# Add download count to names
#build_list="$(head -n 1 Stats3)"
# shellcheck disable=SC2206
#build_list=($build_list)
# shellcheck disable=SC2013
#for var in "${build_list[@]:1}"; do
#i=0
#j=0
#k=0
# shellcheck disable=SC2013
# for i in $(sed -n "/${var}/p" Stats); do
# k="$((k+1))"
# if [ "$k" -eq 3 ]; then break; fi
# if [ "$i" -eq "$i" ] && [ "$i" -gt "$j" ]; then j="$i"; fi
# done
#sed -i "s|${var}|${var}_(${j}x)|g" Stats3
#done
echo "... done"
# Remove series with less than 4 points
sed -i "/^[0-9|-]* [0-9*|-]* [0-9*|-]* -/d" Stats3
# Plot graph
( gnuplot -persist <<-EOFMarker
set title 'Top 10 addons'
set ylabel 'Number of installations'
set xdata time
set datafile missing "-"
set timefmt "%Y-%m-%d"
set format x "%y-%m-%d"
set datafile sep ' '
set autoscale
set terminal png size 500,300
set output 'stats_addons.png'
set term png tiny
plot for [i=2:*] 'Stats3' using 1:i w l title columnhead(i) smooth bezier
EOFMarker
) || ( gnuplot -persist <<-EOFMarker
set title 'Top 10 addons'
set ylabel 'Number of installations'
set xdata time
set datafile missing "-"
set timefmt "%Y-%m-%d"
set format x "%y-%m-%d"
set datafile sep ' '
set autoscale
set terminal png size 500,300
set output 'stats_addons.png'
set term png tiny
plot for [i=2:*] 'Stats3' using 1:i w l title columnhead(i)
EOFMarker
)
#plot for [i=1:*] 'Stats3' using 0:i
rm Stats3
cd .. || true
- name: Create individual stats
run: |
# Prepare data
cp Stats Stats3
# Remove Totals
sed -i "2d" Stats3
# Inverse file
gawk -i inplace '{for(i=NF;i>1;i--)printf "%s ",$i;printf "%s",$1;print ""}' Stats3
# For each addon
# shellcheck disable=SC2013
for line in $(awk '{ print $1 }' Stats3); do
TITLE="${line%% *}"
FOLDER="$(grep -irl "ghcr.io/alexbelgium/$TITLE-{arch}" --include="config.*" . | xargs -r dirname)"
FOLDER="${FOLDER:2}"
echo "$TITLE found in $FOLDER"
# If non null
if [[ "${#FOLDER}" -gt 2 ]]; then
sed -n "/Date /p" Stats3 > "$FOLDER"/StatsTmp
sed -n "/$TITLE /p" Stats3 >> "$FOLDER"/StatsTmp
# Go in folder
cd "$FOLDER" || true
cat StatsTmp
# Transpose data
awk '
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
}
}' StatsTmp > StatsTmp2 && mv StatsTmp2 StatsTmp
#Normalize data
#awk 'FNR==NR{max=($2+0>max)?$2:max;next} {print $1,$2/max}' StatsTmp StatsTmp
# Plot graph
( gnuplot -persist <<-EOFMarker
set title "$TITLE"
set ylabel 'Number of installations'
set xdata time
set datafile missing "-"
set timefmt "%Y-%m-%d"
set format x "%y-%m-%d"
set datafile sep ' '
set autoscale
set terminal png size 500,150
set output "stats.png"
set term png tiny
plot for [i=2:*] 'StatsTmp' using 1:i w l title columnhead(i) smooth bezier
EOFMarker
) || ( gnuplot -persist <<-EOFMarker
set title "$TITLE"
set ylabel 'Number of installations'
set xdata time
set datafile missing "-"
set timefmt "%Y-%m-%d"
set format x "%y-%m-%d"
set datafile sep ' '
set autoscale
set terminal png size 500,150
set output "stats.png"
set term png tiny
plot for [i=2:*] 'StatsTmp' using 1:i w l title columnhead(i)
EOFMarker
) || true
rm StatsTmp || true
cd .. || true
fi || true
done
# Clean files
rm StatsTmp2
rm Stats3
- name: Create global stats
run: |
# Prepare data
cp Stats Stats3
# Inverse file
gawk -i inplace '{for(i=NF;i>1;i--)printf "%s ",$i;printf "%s",$1;print ""}' Stats3
# Only totals
head -n 2 Stats3 > tmp_file && mv tmp_file Stats3
# Transpose data
awk '
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
}
}' Stats3 > StatsTmp && mv StatsTmp .github/Stats3
cd .github || true
sed -i "1d" Stats3
# Plot graph
gnuplot -persist <<-EOFMarker
set title 'Total addons'
set ylabel 'Number of installations'
set xdata time
set datafile missing "-"
set timefmt "%Y-%m-%d"
set format x "%y-%m-%d"
set datafile sep ' '
set key top left autotitle columnheader
set autoscale
set terminal png size 500,300
set output 'stats.png'
set term png tiny
plot 'Stats3' using 1:2 lt rgb 'red' w l title 'Total addons' smooth bezier
EOFMarker
rm Stats3
cd .. || true
- name: Clean
run: |
echo "Starting run"
if [ -f stats.png ]; then rm stats.png; fi
if [ -f Stats3 ]; then rm Stats3; fi
- name: Update stars
run: |
echo "Starting run"
# Get stars
wget -S -O .github/stars.svg https://contrib.rocks/image?repo=Mesteriis/hassio-addons-avm || true
# Get stars2
wget -S -O .github/stars2.svg https://git-lister.onrender.com/api/stars/Mesteriis/hassio-addons-avm?limit=30 || true
# Get stars evolution
wget -S -O .github/starsevol.svg "https://api.star-history.com/svg?repos=Mesteriis/hassio-addons-avm&type=Date" || true
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
message: "GitHub bot : graphs updated"
default_author: github_actions

View File

@@ -1,22 +0,0 @@
---
name: Sync labels
# yamllint disable-line rule:truthy
on:
push:
branches:
- master
paths:
- .github/labels.yml
jobs:
labels:
name: ♻️ Sync labels
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v2.3.4
- name: 🚀 Run Label Syncer
uses: micnncim/action-label-syncer@v1.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,33 +0,0 @@
---
name: Lint
# yamllint disable-line rule:truthy
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
jobs:
json:
name: JSON Lint
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v2.3.4
- name: 🚀 Run JQ
run: |
shopt -s globstar
cat **/*.json | jq '.'
yamllint:
name: YAMLLint
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v2.3.4
- name: 🚀 Run YAMLLint
uses: frenck/action-yamllint@v1.1

View File

@@ -1,21 +0,0 @@
---
name: Lock
# yamllint disable-line rule:truthy
on:
schedule:
- cron: "0 9 * * *"
workflow_dispatch:
jobs:
lock:
name: 🔒 Lock closed issues and PRs
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2.0.3
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: "30"
issue-lock-reason: ""
pr-lock-inactive-days: "1"
pr-lock-reason: ""

69
.github/workflows/on_issues.yml vendored Normal file
View File

@@ -0,0 +1,69 @@
# yamllint disable rule:line-length
---
name: Readme Issues linker
on:
issues:
types: [opened, edited, closed]
workflow_dispatch:
jobs:
ISSUES_linked:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Assign issues
run: |
# Init
echo "Starting"
# Get issues list
curl -s -L https://api.github.com/repos/Mesteriis/hassio-addons-avm/issues > issueslist
# 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
# Clean previously reported issues
sed -i "/Open Issue :/d" "$f"/README.md
sed -i "/Open Request :/d" "$f"/README.md
# If there is an issue with the addon name in title, put a message
COUNTER=0
while [[ $(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].title" issueslist) != null ]]; do
#Increment counter
(( COUNTER=COUNTER+1 )) || true
#Get variables
TITLE="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].title" issueslist)"
TITLE="${TITLE//[<>\$\'\"]/}"
#Check if relevant to addon
SLUG="$(jq -r --arg f "$f" ".slug" "$f"/config.json)"
NAME="$(jq -r --arg f "$f" ".name" "$f"/config.json)"
if [[ "${TITLE,,}" == *"${f,,}"* ]] || [[ "${TITLE,,}" == *"${SLUG,,}"* ]] || [[ "${TITLE,,}" == *"${NAME,,}"* ]]; then
echo "Project $TITLE, $SLUG, $NAME has an issue"
REQ="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].user.login" issueslist)"
URL="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].html_url" issueslist)"
LABEL="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].labels[].name" issueslist)"
DATEISSUE="$(jq -r --arg COUNTER "$COUNTER" ".[$COUNTER].created_at" issueslist)"
DATEISSUE="${DATEISSUE%T*}"
if [[ "$LABEL" == *"bug"* ]]; then
sed -i "1i ## &#9888; Open Issue : [$TITLE (opened ${DATEISSUE})]($URL) by [@${REQ}](https://github.com/$REQ)" "$f"/README.md
elif [[ "$LABEL" == *"enhancement"* ]]; then
sed -i "1i ## &#9888; Open Request : [$TITLE (opened ${DATEISSUE})]($URL) by [@${REQ}](https://github.com/$REQ)" "$f"/README.md
fi
fi
done
fi
done
# Remove issues list
rm issueslist
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
message: "Github bot : issues linked to readme"
default_author: github_actions
commit: -u
fetch: --force
push: --force

40
.github/workflows/onpr_automerge.yaml vendored Normal file
View File

@@ -0,0 +1,40 @@
# yamllint disable rule:line-length
# shellcheck disable=SC2043
---
name: automerge
on:
pull_request_review:
types:
- submitted
issue_comment:
types: created
check_suite:
types:
- completed
status: {}
jobs:
labeler:
runs-on: ubuntu-latest
steps:
- name: Add the automerge label
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/automerge') }}
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['automerge']
})
automerge:
runs-on: ubuntu-latest
needs: [labeler]
steps:
- id: automerge
if: ${{ github.event.issue.pull_request }}
name: automerge
uses: "pascalgn/automerge-action@v0.16.2"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

276
.github/workflows/onpr_check-pr.yaml vendored Normal file
View File

@@ -0,0 +1,276 @@
# yamllint disable rule:line-length
# shellcheck disable=SC2043
---
name: PR Check Build
on:
pull_request:
branches:
- master
jobs:
check-addon-changes:
runs-on: ubuntu-latest
outputs:
changedAddons: ${{ steps.filter.outputs.changes }}
changedChangelogFiles: ${{ steps.changed-files.outputs.changelogs_files }}
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: 📂 Detect changed addons
uses: dorny/paths-filter@v3
id: filter
with:
filters: .github/paths-filter.yml
- name: 📂 Detect chanced files
uses: dorny/paths-filter@v3
id: changed-files
with:
list-files: csv
filters: |
changelogs:
- '**/CHANGELOG.md'
check-changed-changelog:
name: Check if CHANGELOG.md changed
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
runs-on: ubuntu-latest
needs: check-addon-changes
strategy:
fail-fast: false
matrix:
addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }}
steps:
- name: 🔎 Check for updated CHANGELOG.md
shell: bash
run: |
# shellcheck disable=SC2076,SC2059
if [[ ! "${{ needs.check-addon-changes.outputs.changedChangelogFiles }}" =~ "${{ matrix.addon }}/CHANGELOG.md" ]]; then
echo "::error::No new entries in ${{ matrix.addon }} CHANGELOG.md file!"
exit 1
fi
check-addon-label:
name: Check for existance of the addon label
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
runs-on: ubuntu-latest
needs: check-addon-changes
strategy:
fail-fast: false
matrix:
addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }}
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: 🔎 Check if a label for the addon exists
shell: bash
run: |
labeltext=$(sed -nr "/${{ matrix.addon }}/p" '.github/paths-filter.yml')
if [[ -z "$labeltext" ]]; then
echo "::error::There is no label for this addon! Please add it to .github/paths-filter.yml"
exit 1
fi
addon-linter:
name: Addon linting
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
runs-on: ubuntu-latest
needs: check-addon-changes
strategy:
fail-fast: false
matrix:
addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }}
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: 🔎 Run Home Assistant Add-on Lint
uses: frenck/action-addon-linter@v2
with:
path: "./${{ matrix.addon }}"
check-build:
name: Test addon build
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
runs-on: ubuntu-latest
needs: check-addon-changes
strategy:
fail-fast: false
matrix:
addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }}
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: Gather addon info
id: information
uses: frenck/action-addon-information@v1.4
with:
path: "./${{ matrix.addon }}/"
- name: 🗄️ Cache docker layers
uses: actions/cache@v3
with:
path: /tmp/buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.addon }}-${{ hashFiles('**/Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-${{ matrix.addon }}-
- name: 🔖 Create addon image tags
id: tags
shell: bash
run: |
imagetemplate=${{ steps.information.outputs.image }}
version=${{ steps.information.outputs.version }}
echo "Using imagetemplate '$imagetemplate'"
# shellcheck disable=SC2129
echo "armhf=${imagetemplate/\{arch\}/armhf}:${version}" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "armv7=${imagetemplate/\{arch\}/armv7}:${version}" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "aarch64=${imagetemplate/\{arch\}/aarch64}:${version}" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "amd64=${imagetemplate/\{arch\}/amd64}:${version}" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "i386=${imagetemplate/\{arch\}/i386}:${version}" >> "$GITHUB_OUTPUT"
- name: 🏷️ Create addon labels
id: labels
shell: bash
run: |
exit 0
# shellcheck disable=SC2076,SC2059
labels="io.hass.version=${{ steps.information.outputs.version }}"
labels=$(printf '%s' "$labels\nio.hass.name=${{ steps.information.outputs.name }}")
labels=$(printf '%s' "$labels\nio.hass.description=${{ steps.information.outputs.description }}")
labels=$(printf '%s' "$labels\nio.hass.type=addon")
labels=$(printf '%s' "$labels\nio.hass.url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/tree/master/${{ matrix.addon }}")
labels=$(printf '%s' "$labels\norg.opencontainers.image.title=${{ steps.information.outputs.name }}")
labels=$(printf '%s' "$labels\norg.opencontainers.image.description=${{ steps.information.outputs.description }}")
labels=$(printf '%s' "$labels\norg.opencontainers.image.version=${{ steps.information.outputs.version }}")
labels=$(printf '%s' "$labels\norg.opencontainers.image.authors=Poeschl <Poeschl@users.noreply.github.com>")
labels=$(printf '%s' "$labels\norg.opencontainers.image.url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}")
labels=$(printf '%s' "$labels\norg.opencontainers.image.source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/tree/master/${{ matrix.addon }}")
labels=$(printf '%s' "$labels\norg.opencontainers.image.created=$(date -Is)")
labels=$(printf '%s' "$labels\norg.opencontainers.image.revision=${GITHUB_SHA}")
echo "Generic labels: $labels"
armhf_labels=$(printf '%s' "$labels\nio.hass.arch=armhf")
armv7_labels=$(printf '%s' "$labels\nio.hass.arch=armv7")
aarch64_labels=$(printf '%s' "$labels\nio.hass.arch=aarch64")
amd64_labels=$(printf '%s' "$labels\nio.hass.arch=amd64")
i386_labels=$(printf '%s' "$labels\nio.hass.arch=i386")
# allow multiline outputs, see https://github.community/t/set-output-truncates-multiline-strings/16852
armhf_labels="${armhf_labels//$'\n'/'%0A'}"
armv7_labels="${armv7_labels//$'\n'/'%0A'}"
aarch64_labels="${aarch64_labels//$'\n'/'%0A'}"
amd64_labels="${amd64_labels//$'\n'/'%0A'}"
i386_labels="${i386_labels//$'\n'/'%0A'}"
# shellcheck disable=SC2129
echo "armhf=$armhf_labels" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "armv7=$armv7_labels" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "aarch64=$aarch64_labels" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "amd64=$amd64_labels" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "i386=$i386_labels" >> "$GITHUB_OUTPUT"
- name: 💽 Create addon build-args
id: build_args
shell: bash
run: |
# shellcheck disable=SC2129
echo "armhf=BUILD_FROM=$(jq -r .build_from.armhf // empty ${{ steps.information.outputs.build }})" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "armv7=BUILD_FROM=$(jq -r .build_from.armv7 // empty ${{ steps.information.outputs.build }})" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "aarch64=BUILD_FROM=$(jq -r .build_from.aarch64 // empty ${{ steps.information.outputs.build }})" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "amd64=BUILD_FROM=$(jq -r .build_from.amd64 // empty ${{ steps.information.outputs.build }})" >> "$GITHUB_OUTPUT"
# shellcheck disable=SC2129
echo "i386=BUILD_FROM=$(jq -r .build_from.i386 // empty ${{ steps.information.outputs.build }})" >> "$GITHUB_OUTPUT"
- name: 🏗️ Set up QEMU
uses: docker/setup-qemu-action@v3
- name: 🏗️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 💿 Build Addon - armhf
if: ${{ steps.information.outputs.armhf == 'true' }}
uses: docker/build-push-action@v5
with:
context: ${{ matrix.addon }}
push: false
load: true
file: ${{ matrix.addon }}/Dockerfile
tags: ${{ steps.tags.outputs.armhf }}
labels: |
${{ steps.labels.outputs.armhf }}
build-args: ${{ steps.build_args.outputs.armhf }}
cache-from: type=local,src=/tmp/buildx-cache/armhf
cache-to: type=local,dest=/tmp/buildx-cache-new/armhf
- name: 💿 Build Addon - armv7
if: ${{ steps.information.outputs.armv7 == 'true' }}
uses: docker/build-push-action@v5
with:
context: ${{ matrix.addon }}
push: false
load: true
file: ${{ matrix.addon }}/Dockerfile
tags: ${{ steps.tags.outputs.armv7 }}
labels: |
${{ steps.labels.outputs.armv7 }}
build-args: ${{ steps.build_args.outputs.armv7 }}
cache-from: type=local,src=/tmp/buildx-cache/armv7
cache-to: type=local,dest=/tmp/buildx-cache-new/armv7
- name: 💿 Build Addon - aarch64
if: ${{ steps.information.outputs.aarch64 == 'true' }}
uses: docker/build-push-action@v5
with:
context: ${{ matrix.addon }}
push: false
load: true
file: ${{ matrix.addon }}/Dockerfile
tags: ${{ steps.tags.outputs.aarch64 }}
labels: |
${{ steps.labels.outputs.aarch64 }}
build-args: ${{ steps.build_args.outputs.aarch64 }}
cache-from: type=local,src=/tmp/buildx-cache/aarch64
cache-to: type=local,dest=/tmp/buildx-cache-new/aarch64
- name: 💿 Build Addon - amd64
if: ${{ steps.information.outputs.amd64 == 'true' }}
uses: docker/build-push-action@v5
with:
context: ${{ matrix.addon }}
push: false
load: true
file: ${{ matrix.addon }}/Dockerfile
tags: ${{ steps.tags.outputs.amd64 }}
labels: |
${{ steps.labels.outputs.amd64 }}
build-args: ${{ steps.build_args.outputs.amd64 }}
cache-from: type=local,src=/tmp/buildx-cache/amd64
cache-to: type=local,dest=/tmp/buildx-cache-new/amd64
- name: 💿 Build Addon - i386
if: ${{ steps.information.outputs.i386 == 'true' }}
uses: docker/build-push-action@v5
with:
context: ${{ matrix.addon }}
push: false
load: true
file: ${{ matrix.addon }}/Dockerfile
tags: ${{ steps.tags.outputs.i386 }}
labels: |
${{ steps.labels.outputs.i386 }}
build-args: ${{ steps.build_args.outputs.i386 }}
cache-from: type=local,src=/tmp/buildx-cache/i386
cache-to: type=local,dest=/tmp/buildx-cache-new/i386
# Fix for https://github.com/docker/build-push-action/issues/252
- name: 🗄️ Update cache Folder
run: |
rm -rf /tmp/buildx-cache
mv /tmp/buildx-cache-new /tmp/buildx-cache

232
.github/workflows/onpush_builder.yaml vendored Normal file
View File

@@ -0,0 +1,232 @@
# yamllint disable rule:line-length
# inspired from https://github.com/Poeschl/Hassio-Addons
---
name: Builder
env:
BUILD_ARGS: ""
on:
workflow_call:
push:
branches:
- master
paths:
- "**/config.*"
jobs:
correct_path_filters:
runs-on: ubuntu-latest
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: Update path_filters
run: |
# Init
echo "Starting"
# 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
# Add to file
if ! grep "$f:" ".github/paths-filter.yml"; then
echo "$f: $f/config.*" >> ".github/paths-filter.yml"
fi
# Identify addons with true images
if [ "$(jq '.image' "$f/config.json")" != null ]; then
sed -i "/$f/ s/ # Image : yes//g" ".github/paths-filter.yml"
sed -i "/$f/ s/$/ # Image : yes/" ".github/paths-filter.yml"
fi
fi
done
# Sort yaml
sort -t= ".github/paths-filter.yml" -o ".github/paths-filter.yml"
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
commit: -u
message: "GitHub bot : scripts executable"
default_author: github_actions
check-addon-changes:
runs-on: ubuntu-latest
needs: [correct_path_filters]
outputs:
changedAddons: ${{ steps.filter.outputs.changes }}
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: 📂 Detect changed files
uses: dorny/paths-filter@v3
id: filter
with:
filters: .github/paths-filter.yml
correct-CRLF:
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
needs: check-addon-changes
uses: ./.github/workflows/weekly_crlftolf.yaml
make-executable:
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
needs: [check-addon-changes, correct-CRLF]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Make scripts executable
run: |
echo "Starting"
git pull origin master
git config core.filemode true
# shellcheck disable=SC2086,SC2046
#git update-index --chmod=+x $(find "$path" -type f -iname "*.sh")
chmod u+x $(find "$path" -type f -iname "*.sh") || true
#git commit -am "fixing the script permissions..."
env:
path: "./${{ matrix.addon }}"
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
commit: -u
message: "GitHub bot : scripts executable"
default_author: github_actions
lint_config:
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
needs: check-addon-changes
runs-on: ubuntu-latest
strategy:
matrix:
addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }}
steps:
- name: ↩️ Checkout
uses: actions/checkout@v4
- name: 🔎 Run Home Assistant Add-on Lint
uses: frenck/action-addon-linter@v2
with:
path: "./${{ matrix.addon }}"
build:
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
needs: [check-addon-changes, make-executable, correct-CRLF]
runs-on: ubuntu-latest
environment: CR_PAT
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
strategy:
matrix:
addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }}
arch: ["aarch64", "amd64", "armv7"]
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Get information
id: info
uses: home-assistant/actions/helpers/info@master
with:
path: "./${{ matrix.addon }}"
- name: Check if add-on should be built
id: check
env:
HEAD: "${{ github.head_ref }}"
run: |
# shellcheck disable=SC2157,SC2086
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
# shellcheck disable=SC2129
echo "build_arch=true" >> $GITHUB_OUTPUT;
# shellcheck disable=SC2129
echo "image=$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)" >> $GITHUB_OUTPUT;
if [[ -z "$HEAD" ]] && [[ "${{ github.event_name }}" == "push" ]]; then
# shellcheck disable=SC2129
echo "BUILD_ARGS=" >> $GITHUB_ENV;
fi
else
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build";
# shellcheck disable=SC2129
echo "build_arch=false" >> $GITHUB_OUTPUT;
fi
- name: Use action to check for mixed line endings (CRLF and LF)
uses: ymwymw/check-mixed-line-endings@v2
- name: Login to GitHub Container Registry
if: env.BUILD_ARGS != '--test'
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ matrix.addon }} add-on
id: builderstep
if: steps.check.outputs.build_arch == 'true'
uses: home-assistant/builder@master
env:
CAS_API_KEY: ${{ secrets.CAS_API_KEY }}
with:
args: |
${{ env.BUILD_ARGS }} \
--${{ matrix.arch }} \
--target /data/${{ matrix.addon }} \
--image "${{ steps.check.outputs.image }}" \
--docker-hub "ghcr.io/${{ github.repository_owner }}" \
--addon
make-changelog:
if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }}
needs: [check-addon-changes, build]
runs-on: ubuntu-latest
strategy:
matrix:
addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Update changelog for minor versions
run: |
echo "Starting"
# Git pull
git pull || true
cd "$path"
# Get version
if [ -f config.yaml ]; then
version="$(sed -e '/version/!d' -e 's/.*version: //' config.yaml)"
elif [ -f config.json ]; then
version="$(sed -e '/version/!d' -e 's/.*[^"]*"\([^"]*\)"/\1/' config.json)"
version="${version//,}"
else
exit 1
fi
# Exit if test
if [[ "$version" == *"test"* ]]; then exit 0; fi
# Create changelog
touch CHANGELOG.md
# If the version does not exist
if ! grep -q "$version" CHANGELOG.md; then
first_line="$(sed -n '/./p' CHANGELOG.md | head -n 1)"
# If the first line does not start with -
if [[ "$first_line" != "-"* ]]; then
sed -i "1i\- Minor bugs fixed" CHANGELOG.md
fi
sed -i "1i\## $version ($(date '+%d-%m-%Y'))" CHANGELOG.md
#fi
fi
env:
path: "./${{ matrix.addon }}"
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
commit: -u
message: "GitHub bot : changelog"
default_author: github_actions
fetch: --force
push: --force

View File

@@ -0,0 +1,32 @@
# This workflow executes several linters on changed files based on languages used in your code base whenever
# you push a code or open a pull request.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/github/super-linter
---
name: Lint On Change
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
run-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Code Base
uses: docker://github/super-linter:slim-v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_NATURAL_LANGUAGE: false

View File

@@ -1,54 +0,0 @@
---
name: Repository Updater
# yamllint disable-line rule:truthy
on:
repository_dispatch:
types: ["update"]
jobs:
publish:
name: Publish add-on update
runs-on: ubuntu-latest
steps:
- name: 🚀 Run Repository Updater
uses: hassio-addons/repository-updater@v1.1
with:
addon: ${{ github.event.client_payload.addon }}
repository: ${{ github.repository }}
token: ${{ secrets.UPDATER_TOKEN }}
announce:
name: Announce add-on update
needs: publish
runs-on: ubuntu-latest
steps:
- name: 📢 Announce on Discord server
uses: sarisia/actions-status-discord@v1.8.6
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
nodetail: true
username: ${{ github.event.client_payload.name }}
avatar_url: |
https://raw.githubusercontent.com/${{ github.repository }}/master/${{ github.event.client_payload.addon }}/icon.png
title: ":arrow_up: ${{ github.event.client_payload.name }} ${{ github.event.client_payload.version }}"
image: |
https://raw.githubusercontent.com/${{ github.repository }}/master/${{ github.event.client_payload.addon }}/logo.png
description: |
A new version of the ${{ github.event.client_payload.name }} add-on has been published.
**Version**: `${{ github.event.client_payload.version }}`
**Release notes**:
<https://github.com/${{ github.event.client_payload.repository }}/releases/tag/${{ github.event.client_payload.version }}>
- name: 📢 Announce on Twitter
uses: devigned/go-twitter-action@v1.0.2
with:
apiKey: ${{ secrets.TWITTER_API_KEY }}
apiKeySecret: ${{ secrets.TWITTER_API_SECRET }}
accessToken: ${{ secrets.TWITTER_ACCESS_TOKEN }}
accessTokenSecret: ${{ secrets.TWITTER_ACCESS_SECRET }}
message: |
⬆️ ${{ github.event.client_payload.name }} ${{ github.event.client_payload.version }}
https://github.com/${{ github.event.client_payload.repository }}/releases/tag/${{ github.event.client_payload.version }}

View File

@@ -1,40 +0,0 @@
---
name: Stale
# yamllint disable-line rule:truthy
on:
schedule:
- cron: "0 8 * * *"
workflow_dispatch:
jobs:
stale:
name: 🧹 Clean up stale issues and PRs
runs-on: ubuntu-latest
steps:
- name: 🚀 Run stale
uses: actions/stale@v3.0.19
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 30
days-before-close: 7
remove-stale-when-updated: true
stale-issue-label: "stale"
exempt-issue-labels: "no-stale,help-wanted"
stale-issue-message: >
There hasn't been any activity on this issue recently, so we
clean up some of the older and inactive issues.
Please make sure to update to the latest version and
check if that solves the issue. Let us know if that works for you
by leaving a comment 👍
This issue has now been marked as stale and will be closed if no
further activity occurs. Thanks!
stale-pr-label: "stale"
exempt-pr-labels: "no-stale"
stale-pr-message: >
There hasn't been any activity on this pull request recently. This
pull request has been automatically marked as stale because of that
and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

View File

@@ -1,75 +0,0 @@
---
name: Translations Download
# yamllint disable-line rule:truthy
on:
schedule:
- cron: "0 8 * * *"
workflow_dispatch:
workflow_run:
workflows: ["Translations Upload"]
branches: [master]
types:
- completed
jobs:
json:
name: Download Translations
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- name: 🏗 Set up yq
uses: frenck/action-setup-yq@v1.0.0
- name: 🏗 Set up the Lokalise CLI
uses: frenck/action-setup-lokalise@v1.0.0
- name: ⤵️ Download translations
run: |
echo "Downloading translations to lokalise"
lokalise2 file download \
--token "${LOKALISE_TOKEN}" \
--project-id "${LOKALISE_PROJECT}" \
--format yaml \
--original-filenames=false \
--export-empty-as base \
--bundle-structure ".translations/%LANG_ISO%.yaml"
env:
LOKALISE_TOKEN: ${{ secrets.LOKALISE_TOKEN }}
LOKALISE_PROJECT: ${{ secrets.LOKALISE_PROJECT }}
- name: 🚀 Process translations
run: |
addons=$(yq e '.addons | keys | .[]' .addons.yml)
mkdir -p .translations
for file in .translations/*.yaml;
do
filename=$(basename "${file}")
language="${filename%.*}"
if [[ "${language}" == "en" ]]; then
continue
fi
echo "Processing downloaded translations in ${language}..."
while read addon;
do
if [[ -f "${addon}/translations/en.yaml" ]];
then
echo "Processing downloaded translations in ${language} for ${addon}..."
yq e ".${addon}" "${file}" \
> "${addon}/translations/${filename}"
fi
done <<<"${addons}"
done
- name: 🚀 Commit changes
continue-on-error: true
run: |
git config --local user.email "action@github.com"
git config --local user.name "${GITHUB_ACTOR}"
git add .
git commit -m "🌍 Updating translations" -a
- name: 🚀 Push changes
uses: ad-m/github-push-action@v0.6.0
continue-on-error: true
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

View File

@@ -1,53 +0,0 @@
---
name: Translations Upload
# yamllint disable-line rule:truthy
on:
workflow_dispatch:
workflow_run:
workflows: ["Repository Updater"]
branches: [master]
types:
- completed
jobs:
upload:
name: Upload Translations
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v2.3.4
- name: 🏗 Set up yq
uses: frenck/action-setup-yq@v1.0.0
- name: 🏗 Set up the Lokalise CLI
uses: frenck/action-setup-lokalise@v1.0.0
- name: 🚀 Combine translations
run: |
addons=$(yq e '.addons | keys | .[]' .addons.yml)
mkdir -p .translations
while read addon;
do
if [[ -f "${addon}/translations/en.yaml" ]];
then
echo "Prepping translation upload for $addon..."
ADDON="${addon}" \
yq e '{env(ADDON): .}' "${addon}/translations/en.yaml" \
> ".translations/${addon}.yaml"
fi
done <<<"${addons}"
echo "Combining translation files..."
yq ea '. as $item ireduce ({}; . * $item)' ./.translations/*.yaml > translations.yaml
- name: 🚀 Upload translations
run: |
echo "Uploading translations to lokalise"
lokalise2 file upload \
--apply-tm \
--lang-iso en \
--poll \
--token "${LOKALISE_TOKEN}" \
--project-id "${LOKALISE_PROJECT}" \
--file translations.yaml
env:
LOKALISE_TOKEN: ${{ secrets.LOKALISE_TOKEN }}
LOKALISE_PROJECT: ${{ secrets.LOKALISE_PROJECT }}

View File

@@ -0,0 +1,76 @@
# This workflow executes several linters on changed files based on languages used in your code base whenever
# you push a code or open a pull request.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/github/super-linter
---
name: Lint Code Base
on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
make-executable:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Make scripts executable
run: |
echo "Starting"
git config core.filemode true
# shellcheck disable=SC2086,SC2046
#git update-index --chmod=+x $(find . -type f -iname "*.sh")
chmod u+x $(find . -type f -iname "*.sh")
#git commit -am "fixing the script permissions..."
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
commit: -u
message: "GitHub bot : scripts executable"
default_author: github_actions
run-lint:
runs-on: ubuntu-latest
needs: make-executable
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout the code base
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
####################
# Run Super Linter #
####################
- name: Lint Code Base
uses: docker://github/super-linter:slim-v4
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_NATURAL_LANGUAGE: false
ACTION_ACTIONLINT_DISABLE_ERRORS: true
check_crlf:
name: Check CRLF action
runs-on: ubuntu-latest
steps:
- name: Checkout repository contents
uses: actions/checkout@v4
- name: Use action to check for CRLF endings
uses: erclu/check-crlf@v1.2.0
- name: check-mixed-line-endings
uses: ymwymw/check-mixed-line-endings@v2

36
.github/workflows/weekly_addons_updater vendored Normal file
View File

@@ -0,0 +1,36 @@
# yamllint disable rule:line-length
---
name: Weekly addons update
on:
workflow_call:
workflow_dispatch:
jobs:
stats_graphs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Install bashio
run: |
# Install bashio
if grep -q -rnw "$files/" -e 'bashio' && [ ! -f "/usr/bin/bashio" ]; then
[ "$VERBOSE" = true ] && echo "install bashio"
BASHIO_VERSION="0.14.3"
mkdir -p /tmp/bashio
curl -f -L -s -S "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio
mv /tmp/bashio/lib /usr/lib/bashio
ln -s /usr/lib/bashio/bashio /usr/bin/bashio
rm -rf /tmp/bashio
fi
- name: Run script
run: |
mkdir -p /data
echo "{" >> /data/config.json
echo " repository=\"Mesteriis/hassio-addons-avm\"," >> /data/config.json
echo " gituser=\"Mesteriis/hassio-addons-avm\"," >> /data/config.json
echo " gitapi=\"Mesteriis/hassio-addons-avm\"," >> /data/config.json
echo " gitmail=\"Mesteriis/hassio-addons-avm\"," >> /data/config.json
echo " verbose=false" >> /data/config.json
echo "}" >> /data/config.json
./addons_updater/rootfs/etc/cont-init.d/99-run.sh

View File

@@ -0,0 +1,43 @@
name: Weekly bash beautify
on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
concurrency:
group: lint-bash-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
lint-bash:
name: Lint Bash Scripts
runs-on: ubuntu-latest
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Set up Python Environment
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Beautysh
run: pip install beautysh
- name: Run Beautysh
run: |
find . -name '*.sh' -print0 | xargs -0 beautysh --indent-size 4
shopt -s globstar nullglob
if compgen -G "**/*.sh" > /dev/null; then
beautysh -- **/*.sh --indent-size 4 --check
fi
shopt -u globstar nullglob
- name: Create New Pull Request If Needed
uses: peter-evans/create-pull-request@v5
with:
title: "Github bot : script beautyshied"
branch-suffix: timestamp
commit-message: "Github bot : script beautyshied"

54
.github/workflows/weekly_crlftolf.yaml vendored Normal file
View File

@@ -0,0 +1,54 @@
# yamllint disable rule:line-length
---
# This workflow finds and fixes CRLF endings in a repository
name: Fix CRLF Endings
on:
workflow_call:
workflow_dispatch:
jobs:
crlf-to-lf:
runs-on: ubuntu-latest
steps:
- name: Checkout repository contents
uses: actions/checkout@v4
- name: Use action to check for CRLF endings
uses: erclu/check-crlf@v1
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
message: "Github bot : CRLF corrected"
default_author: github_actions
fix-crlf:
name: Fix CRLF Endings
runs-on: ubuntu-latest # Use a Linux runner
steps:
- name: Checkout repository contents
uses: actions/checkout@v4 # Use the checkout action
- name: Find files with CRLF endings
uses: erclu/check-crlf@v1.2.0 # Use the check-crlf action
id: check-crlf # Assign an id to this step
with:
# Specify the paths to check
path: |
./*
!.git
!*.png
!*.jpg
!*.bin
- name: Apply dos2unix to files with CRLF endings
run: |
# Loop through each file and apply dos2unix
# shellcheck disable=SC2043
for f in ${{ steps.check-crlf.outputs.files }}; do
# Apply dos2unix and keep the original timestamp
dos2unix -k "$f"
done
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
message: "Github bot : CRLF corrected"
default_author: github_actions

View File

@@ -0,0 +1,37 @@
# Compress images on demand (workflow_dispatch), and at 11pm every Sunday (schedule).
# Open a Pull Request if any images can be compressed.
---
name: Compress Images
on:
workflow_dispatch:
schedule:
- cron: '00 23 * * 0'
jobs:
calibre:
name: calibreapp/image-actions
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Compress Images
id: calibre
uses: calibreapp/image-actions@main
with:
# The `GITHUB_TOKEN` is automatically generated by GitHub and scoped only to the repository that is currently running the action. By default, the action cant update Pull Requests initiated from forked repositories.
# See https://docs.github.com/en/actions/reference/authentication-in-a-workflow and https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions
githubToken: ${{ secrets.GITHUB_TOKEN }}
compressOnly: true
jpegQuality: '60'
jpegProgressive: false
pngQuality: '60'
webpQuality: '60'
- name: Commit if needed
if: steps.calibre.outputs.markdown != ''
uses: EndBug/add-and-commit@v9
with:
message: "Github bot : image compressed"
default_author: github_actions
body: ${{ steps.calibre.outputs.markdown }}

31
.github/workflows/weekly_sortjson.yaml vendored Normal file
View File

@@ -0,0 +1,31 @@
# yamllint disable rule:line-length
---
name: Weekly sort json
on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
sort_json:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Run script file
id: sort
run: |
for files in */*.json; do
echo "Sorting $files"
jq --sort-keys . "$files" > config2.json && cat config2.json > "$files" && rm config2.json
echo "changed=1" >> "$GITHUB_OUTPUT"
done
shell: bash
- name: Create New Pull Request If Needed
if: steps.sort.outputs.changed != ''
uses: peter-evans/create-pull-request@v5
with:
title: "Github bot : json sorted"
branch-suffix: timestamp
commit-message: "Github bot : json sorted"

106
.github/workflows/weekly_stats.yaml vendored Normal file
View File

@@ -0,0 +1,106 @@
# yamllint disable rule:line-length
---
name: Generate weekly stats
on:
schedule:
- cron: "0 12 * * 5"
workflow_dispatch:
jobs:
stats_updater:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Create stats
run: |
echo "Starting"
COUNT=0
COUNT1=0
COUNT2=0
COUNT3=0
# Make sure file exists
file=Stats
touch "$file"
rm "$file"2
if ! grep -q "Date" "$file"; then
sed -i "1i Date" "$file"
fi
# Add new column
sed -i 's/^/- /' "$file"
# Add date
sed -i "/Date/s|^-|$(date '+%Y-%m-%d')|" "$file"
# Go through all folders, add to filters if not existing
# shellcheck disable=SC2086
for f in $( find -- * -maxdepth 0 -type d | sort -r ); do
DOWNLOADS=0
if [ -f "$f"/config.json ] && jq -e '.image' "$f/config.json"; then
SLUG="$(jq -r '.image' "$f/config.json" | awk -F 'alexbelgium/|-{arch' '{print $2}')"
if [[ "$(jq '.arch[]' "$f/config.json")" == *"armv7"* ]]; then
ARCH=armv7 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/Mesteriis/hassio-addons-avm/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/Mesteriis/hassio-addons-avm/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//,/}"
COUNT1="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
else COUNT1="-"; fi
if [[ "$(jq '.arch[]' "$f/config.json")" == *"amd64"* ]]; then
ARCH=amd64 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/Mesteriis/hassio-addons-avm/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/Mesteriis/hassio-addons-avm/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//,/}"
COUNT2="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
else COUNT2="-"; fi
if [[ "$(jq '.arch[]' "$f/config.json")" == *"aarch64"* ]]; then
ARCH=aarch64 && COUNT="$(curl --connect-timeout 5 -f -s -L https://github.com/Mesteriis/hassio-addons-avm/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/Mesteriis/hassio-addons-avm/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//,/}"
COUNT3="$COUNT"
echo "$COUNT $ARCH users with $SLUG" && DOWNLOADS="$(( DOWNLOADS + COUNT))"
else COUNT3="-";fi
echo "$SLUG $DOWNLOADS $COUNT1 $COUNT2 $COUNT3" >> "$file"2
# Create line if not existing
if ! grep -q "${SLUG}$" "$file"; then
sed -i "\$a$SLUG" "$file"
# shellcheck disable=SC2046
for i in $(seq $(head -n 1 $file | tr -cd ' \t' | wc -c )); do
echo "$i"
sed -i "/$SLUG/s|^|- |" "$file"
done
fi
# Add data
sed -i "/${SLUG}$/s|^-|$DOWNLOADS|" "$file"
fi
done
# Add total
SLUG=TOTAL
if ! grep -q "$SLUG$" "$file"; then
sed -i "1a$SLUG" "$file"
# shellcheck disable=SC2046
for i in $(seq $(head -n 1 $file | tr -cd ' \t' | wc -c )); do
echo "$i"
sed -i "/$SLUG$/s|^|- |" "$file"
done
fi
DOWNLOADS="$(awk 'FNR > 2 {SUM+=$1}END{print SUM}' Stats)"
sed -i "/$SLUG$/s|^-|$DOWNLOADS|" "$file"
# Sort file
(head -n 2 "$file" && tail -n +3 "$file" | sort -k1 -r -n) > tmp && mv tmp "$file"
sed -i "1i Name Total armv7 amd64 aarch64" "$file"2
sed -i "1a ------------------------------" "$file"2
#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)"
- name: Commit if needed
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message : "Github bot : stats updated"
Generate_graphs:
needs: stats_updater
uses: ./.github/workflows/helper_stats_graphs.yaml