From f97cb04159de107af3c00024e408d4005375cd44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sun, 27 Nov 2022 00:43:37 +0000 Subject: [PATCH] ci: skip upload step when api key is empty (usually happens for PR) --- scripts/upload-packages.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/upload-packages.sh b/scripts/upload-packages.sh index d2ef758..06c3d43 100755 --- a/scripts/upload-packages.sh +++ b/scripts/upload-packages.sh @@ -4,11 +4,16 @@ set -ex cd "$(git rev-parse --show-toplevel)" +if [ -z "$GITEA_API_KEY" ]; then + echo "GITEA_API_KEY is empty, skip upload." + exit 0 +fi + URL_BASE="$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build" for ZIP_NAME in *.zip; do - UPLOAD_URL="${URL_BASE}/${DRONE_BUILD_NUMBER}/${ZIP_NAME}" - sha256sum "${ZIP_NAME}" - curl -sLifu "um-release-bot:$GITEA_API_KEY" -T "${ZIP_NAME}" "${UPLOAD_URL}" - echo "Uploaded to: ${UPLOAD_URL}" + UPLOAD_URL="${URL_BASE}/${DRONE_BUILD_NUMBER}/${ZIP_NAME}" + sha256sum "${ZIP_NAME}" + curl -sLifu "um-release-bot:$GITEA_API_KEY" -T "${ZIP_NAME}" "${UPLOAD_URL}" + echo "Uploaded to: ${UPLOAD_URL}" done