-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·29 lines (21 loc) · 802 Bytes
/
entrypoint.sh
File metadata and controls
executable file
·29 lines (21 loc) · 802 Bytes
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
#!/bin/bash
URL=$1
TASKID=$(curl -L -X POST -H 'Content-Type: application/json' \
--data-raw '{
"address": "'$URL'"
}' 'https://analyse.imagekit.io/analysis' | jq -r '.taskId')
check() {
STATE=$(curl -L -X GET 'https://analyse.imagekit.io/status/'$TASKID'' | jq -r '.state')
}
check #1st execution
while [ "$STATE" == "processing" ]; do
sleep 10
check
done
RESULT=$(curl -L -H 'Content-Type: application/json' 'https://analyse.imagekit.io/status/'$TASKID'')
SAVINGS=$(echo $RESULT | jq -r '.report.finalFormattedResults.totalImagePercentSaving')
PROTIP=$(echo $RESULT | jq -r '.report.finalFormattedResults.proTip')
echo "::set-output name=savings::$SAVINGS%"
echo "::set-output name=protip::$PROTIP"
echo "::set-output name=report-url::https://analyse.imagekit.io/status/'$TASKID'"
exit 0