34 lines
1.3 KiB
Bash
Executable file
34 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# shellcheck disable=SC3040
|
|
set -eu -o pipefail
|
|
|
|
readonly REPOS="backports user"
|
|
readonly BASEBRANCH=$GITHUB_BASE_REF
|
|
readonly TARGET_REPO=$CI_ALPINE_REPO
|
|
|
|
apkgs=$(find package -type f -name "*.apk")
|
|
|
|
for apk in $apkgs; do
|
|
branch=$(echo $apk | awk -F '/' '{print $2}')
|
|
arch=$(echo $apk | awk -F '/' '{print $3}')
|
|
name=$(echo $apk | awk -F '/' '{print $4}')
|
|
|
|
if [ "$(curl -s $GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/pulls/$GITHUB_EVENT_NUMBER | jq .draft)" == "true" ]; then
|
|
# if draft, send to -testing branch
|
|
branch="$branch-testing"
|
|
else
|
|
# if not draft, assume that this was sent to $branch-testing and nuke it
|
|
curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN -X DELETE $TARGET_REPO/$BASEBRANCH/$branch-testing/$arch/$name
|
|
fi
|
|
|
|
echo "Sending $name of arch $arch to $TARGET_REPO/$BASEBRANCH/$branch"
|
|
return=$(curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN --upload-file $apk $TARGET_REPO/$BASEBRANCH/$branch 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/$branch/$arch/$name
|
|
curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN --upload-file $apk $TARGET_REPO/$BASEBRANCH/$branch
|
|
fi
|
|
done
|
|
|