Add a comment with new Flatpak packages list #2007

This commit is contained in:
Sergei Eremenko 2023-09-07 13:03:43 +03:00
parent 4152347cb8
commit 2b997a3f66
No known key found for this signature in database
GPG key ID: AB6D54C1C16D2507

View file

@ -9,9 +9,14 @@ API_ENDPOINT="https://api.github.com/repos/PapirusDevelopmentTeam/papirus-icon-t
unchecked_apps_list="$(mktemp -u)"
completed_apps_list="$(mktemp -u)"
missing_apps_list="$(mktemp -u)"
new_apps_list="$(mktemp -u)"
_cleanup() {
rm -f "$unchecked_apps_list" "$completed_apps_list" "$missing_apps_list"
rm -f \
"$unchecked_apps_list" \
"$completed_apps_list" \
"$missing_apps_list" \
"$new_apps_list"
}
trap _cleanup EXIT HUP INT TERM
@ -24,6 +29,10 @@ curl -s "$API_ENDPOINT" |
env MARKDOWN=1 bash "$SCRIPT_DIR/missing_flathub_apps.sh" > "$missing_apps_list"
# Create a list of new Flatpak packages
comm -13 <(sort "$unchecked_apps_list") <(sort "$missing_apps_list") |
sed 's/\[ \][ ]//' > "$new_apps_list"
if ! diff -w --brief "$unchecked_apps_list" "$missing_apps_list" >/dev/null; then
echo "Uptading issue #${API_ENDPOINT##*/} ..." >&2
jq --compact-output --raw-input --slurp '. as $body | {$body}' \
@ -32,8 +41,24 @@ if ! diff -w --brief "$unchecked_apps_list" "$missing_apps_list" >/dev/null; the
--silent \
--output /dev/null \
--header "Authorization: token ${GITHUB_TOKEN?is not set}" \
--header 'Accept: application/vnd.github+json' \
--header 'Content-Type: application/json' \
--header 'X-GitHub-Api-Version: 2022-11-28' \
--data @- \
--request PATCH "$API_ENDPOINT"
fi
if [ -s "$new_apps_list" ]; then
echo "Add a comment with new apps list ..." >&2
jq --compact-output --raw-input --slurp '. as $body | {$body}' \
"$new_apps_list" |
curl \
--silent \
--output /dev/null \
--header "Authorization: token ${GITHUB_TOKEN?is not set}" \
--header 'Accept: application/vnd.github+json' \
--header 'Content-Type: application/json' \
--header 'X-GitHub-Api-Version: 2022-11-28' \
--data @- \
--request POST "$API_ENDPOINT/comments"
fi