-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·45 lines (40 loc) · 1.4 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
REPOSITORY=$1
PACKAGE=$2
VERSION=$3
SOURCE_PATH=$4
UPLOAD_PATH=$5
EXPLODE=$6
OVERRIDE=$7
PUBLISH=$8
UPLOADED=0
for FILE in ${SOURCE_PATH}; do
UPLOAD_URL=${INPUT_API_URL}/content/${INPUT_API_USER}/${REPOSITORY}/${UPLOAD_PATH}/$(basename $FILE)
echo "=== Uploading ${FILE} to ${UPLOAD_URL}"
RESULT=$(curl -T ${FILE} \
-u${INPUT_API_USER}:${INPUT_API_KEY} \
-H "X-Bintray-Package:${PACKAGE}" \
-H "X-Bintray-Version:${VERSION}" \
-H "X-Bintray-Override:${OVERRIDE}" \
-H "X-Bintray-Explode:${EXPLODE}" \
${UPLOAD_URL})
if [ "$(echo ${RESULT} | jq -r '.message')" != "success" ]; then
echo "=== Failed to upload ${FILE} with response: ${RESULT}"
exit 1
else
UPLOADED=$((UPLOADED+1))
echo "=== ${FILE} uploaded successfully"
fi
done
if [ "$PUBLISH" == "true" ]; then
echo "=== Publishing repository [${REPOSITORY}] - package [${PACKAGE}] - version [${VERSION}]"
PUBLISH_RESULT=$(curl -X POST \
-u${INPUT_API_USER}:${INPUT_API_KEY} \
${INPUT_API_URL}/content/${INPUT_API_USER}/${REPOSITORY}/${PACKAGE}/${VERSION}/publish)
if [ $(echo ${PUBLISH_RESULT} | jq -r '.files') -lt ${UPLOADED} ]; then
echo "=== Not all files are published successfully, response: ${PUBLISH_RESULT}"
exit 1
else
echo "=== Published successfully"
fi
fi