-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
70 lines (59 loc) · 2.64 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
set -e
echo "Authenticating using $INPUT_CREDENTIALS_TYPE";
# Authenticate to the server
if [ $INPUT_CREDENTIALS_TYPE == "username" ];
then
sh -c "jfrog rt c action-server --interactive=false --url=$INPUT_URL --user=$INPUT_USER --password=$INPUT_PASSWORD"
elif [ $INPUT_CREDENTIALS_TYPE == "apikey" ];
then
sh -c "jfrog rt c action-server --interactive=false --url=$INPUT_URL --apikey=$INPUT_APIKEY"
elif [ $INPUT_CREDENTIALS_TYPE == "accesstoken" ];
then
sh -c "jfrog rt c action-server --interactive=false --url=$INPUT_URL --access-token=$INPUT_ACCESS_TOKEN"
fi
sh -c "jfrog rt use action-server"
# Set working directory if specified
if [ $INPUT_WORKING_DIRECTORY != '.' ];
then
cd $INPUT_WORKING_DIRECTORY
fi
rest=$INPUT_ARTIFACTFROM
while [ -n "$rest" ] ; do
str=${rest%%;*} # Everything up to the first ';'
# Trim up to the first ';' -- and handle final case, too.
[ "$rest" = "${rest/;/}" ] && rest= || rest=${rest#*;}
str="$(echo -e "${str}" | sed -e 's/^[[:space:]]*//')"
if [ -z "$str" ]
then
echo "Extra semicolons detected. Safe Skip"
else
echo "+ \"$str\""
echo "[Info] Uploading artifact: jfrog rt u $str $INPUT_ARTIFACTTO --build-name=$INPUT_BUILDNAME --build-number=$INPUT_BUILDNUMBER"
outputUpload=$( sh -c "jfrog rt u $str $INPUT_ARTIFACTTO --build-name=$INPUT_BUILDNAME --build-number=$INPUT_BUILDNUMBER" )
echo "$outputUpload" > "${HOME}/${GITHUB_ACTION}.log"
echo "$outputUpload"
fi
done
## Log command for info
#echo "[Info] Uploading artifact: jfrog rt u $INPUT_ARTIFACTFROM $INPUT_ARTIFACTTO --build-name=$INPUT_BUILDNAME --build-number=$INPUT_BUILDNUMBER"
## Capture output
#outputUpload=$( sh -c "jfrog rt u $INPUT_ARTIFACTFROM $INPUT_ARTIFACTTO --build-name=$INPUT_BUILDNAME --build-number=$INPUT_BUILDNUMBER" )
## Write for further analysis if needed
#echo "$outputUpload" > "${HOME}/${GITHUB_ACTION}.log"
## Write output to STDOUT
#echo "$outputUpload"
# Conditional build publish
if [ $INPUT_PUBLISH == "true" ];
then
echo "[Info] Pushing build info: jfrog rt bce $INPUT_BUILDNAME $INPUT_BUILDNUMBER"
outputPushInfo=$( sh -c "jfrog rt bce $INPUT_BUILDNAME $INPUT_BUILDNUMBER")
echo "[Info] Pushing build artifacts: jfrog rt bp $INPUT_BUILDNAME $INPUT_BUILDNUMBER"
outputPublish=$( sh -c "jfrog rt bp $INPUT_BUILDNAME $INPUT_BUILDNUMBER")
# echo "[Info] Promoting build artifacts: jfrog rt bp $INPUT_BUILDNAME $INPUT_BUILDNUMBER"
# outputPublish=$( sh -c "jfrog rt bpr $INPUT_BUILDNAME $INPUT_BUILDNUMBER lafayette_release")
echo "$outputPushInfo" > "${HOME}/${GITHUB_ACTION}.log"
echo "$outputPublish" > "${HOME}/${GITHUB_ACTION}.log"
echo "$outputPushInfo"
echo "$outputPublish"
fi