Skip to content

Automatic update of versions #158

Automatic update of versions

Automatic update of versions #158

name: Example repository checks
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Verify that all examples have an entry in top-README
run: |
# Find directories that do not start with dot
acap_list="$(find . -maxdepth 1 -type d -printf '%f\n' |grep -v '^[.]' | sort)"
# Find lines starting with '* ['
# The grep removes anything but '[*]', then remove entries with space
# or capital letter and finally removes the brackets.
endline="$(sed -n '/## Docker Hub images/=' README.md)"
readme_examples="$(sed -n "1,${endline}!d ; /* \[/p" README.md | grep -oe '\[.*\]' | grep -v '[A-Z ]' | grep -oe '[0-9a-z-]*')"
# Control that all examples have an entry in README
common=$(printf "${acap_list}\n${readme_examples}" | sort | uniq -d)
unique=$(printf "${acap_list}\n${readme_examples}" | sort | uniq -u)
[ -z "$unique" ] || {
printf "\n\nERROR: Mismatch between example directories and entries in README.md:\n$unique\n\n"
exit 1
}
printf "\n\nAll example directories have entries in README.md:\n$common\n\n"
# Control that the README entries are sorted alphabetically ascending
sorted_list="$(printf "$readme_examples" | sort)"
[ "$readme_examples" = "$sorted_list" ] || {
printf "\n\nERROR: The list of example entries in README.md is not sorted alphabetically(left column has current order):\n"
diff -y <(echo "$readme_examples") <(echo "$sorted_list")
exit 1
}
printf "\n\nAll examples are sorted in alphabetical order in README.md."