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