qports/.forgejo/bin/deploy.sh
Antoine Martin 69eb028438
Some checks failed
/ lint (pull_request) Successful in 25s
/ build-edge (pull_request) Successful in 32s
/ deploy-edge (pull_request) Failing after 1m41s
forgejo-ci: initial
2024-08-16 01:16:26 -04:00

33 lines
1 KiB
Bash
Executable file

#!/bin/sh
# shellcheck disable=SC3040
set -eu -o pipefail
readonly BASEBRANCH=$(grep PRETTY_NAME /etc/os-release | awk '{print $3}' | tr -d '"')
readonly TARGET_REPO=$CI_ALPINE_REPO
get_qubes_release() {
case $GITHUB_BASE_REF in
r*) echo $GITHUB_BASE_REF;;
main) echo r4.3;;
esac
}
readonly QUBES_REL=$(get_qubes_release)
apkgs=$(find package -type f -name "*.apk")
for apk in $apkgs; do
arch=$(echo $apk | awk -F '/' '{print $3}')
name=$(echo $apk | awk -F '/' '{print $4}')
echo "Sending $name of arch $arch to $TARGET_REPO/$BASEBRANCH/qubes-$QUBES_REL"
return=$(curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN --upload-file $apk $TARGET_REPO/$BASEBRANCH/qubes-$QUBES_REL 2>&1)
echo $return
if [ "$return" == "package file already exists" ]; then
echo "Package already exists, refreshing..."
curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN -X DELETE $TARGET_REPO/$BASEBRANCH/qubes-$QUBES_REL/$arch/$name
curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN --upload-file $apk $TARGET_REPO/$BASEBRANCH/qubes-$QUBES_REL
fi
done