#!/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}') 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