1+ #! /bin/bash
2+
3+ export THIRD_PARTY_SERVICES=(
4+ caddy
5+ postgres-migrate
6+ kratos-migrate
7+ kratos
8+ oathkeeper
9+ object-storage
10+ qdrant
11+ )
12+
13+
14+ function get_docker_compose_services() {
15+ for service in $( docker compose config --services) ; do
16+ is_third_party_service=" false"
17+ for tps in ${THIRD_PARTY_SERVICES[@]} ; do
18+ if [[ " ${service} " == " ${tps} " ]]; then
19+ is_third_party_service=" true"
20+ fi
21+ done
22+
23+ if [[ " ${is_third_party_service} " == " false" ]]; then
24+ echo " ${service} "
25+ fi
26+ done
27+ }
28+
29+ function get_latest_app_tag() {
30+ owner=$1
31+ app=$2
32+ gh api \
33+ -H " Accept: application/vnd.github+json" \
34+ -H " X-GitHub-Api-Version: 2022-11-28" \
35+ /repos/${owner} /${app} /releases/latest | jq -r ' .tag_name'
36+ }
37+
38+ function fetch_updated_apps() {
39+ owner=$1
40+ echo " " > diff.json
41+
42+ for app in $( get_docker_compose_services) ; do
43+ echo " Fetching ${app} ..."
44+ latest_app_tag=$( get_latest_app_tag ${owner} ${app} )
45+ latest_app_tag_dttm=$( gh api \
46+ -H " Accept: application/vnd.github+json" \
47+ -H " X-GitHub-Api-Version: 2022-11-28" \
48+ /repos/${owner} /${app} /releases/latest | jq -r ' .published_at' )
49+ total_commits=$( gh api \
50+ -H " Accept: application/vnd.github+json" \
51+ -H " X-GitHub-Api-Version: 2022-11-28" \
52+ /repos/${owner} /${app} /releases/latest | jq -r ' .published_at' )
53+
54+ JQ_QUERY=' {
55+ app: "' ${app} ' ",
56+ latest_tag: "' ${latest_app_tag} ' ",
57+ latest_tag_dttm: "' ${latest_app_tag_dttm} ' ",
58+ total_commits: .total_commits,
59+ commits: [
60+ .commits[].commit | {
61+ author: .author.name,
62+ date: .author.date,
63+ message: .message
64+ }
65+ ]
66+ }'
67+
68+ gh api \
69+ -H " Accept: application/vnd.github+json" \
70+ -H " X-GitHub-Api-Version: 2022-11-28" \
71+ /repos/${owner} /${app} /compare/${latest_app_tag} ...dev \
72+ | jq -r " ${JQ_QUERY} " >> diff.json
73+ done
74+
75+ jq --slurp ' .[] | sort_by(.app)' diff.json > __diff.json
76+ mv __diff.json diff.json
77+ }
0 commit comments