Skip to content

Commit

Permalink
Merge pull request #9 from salihoglu87/master
Browse files Browse the repository at this point in the history
add curl retry and php -v and fixed ENV names
  • Loading branch information
runningman84 authored Mar 10, 2023
2 parents 58ae002 + cf6853a commit fbd26f9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions report-versions.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/bash
set -e
#check if APP_STATUS_API and STATUS_API_KEY are not empty
if [[ -n "$APP_STATUS_API" && -n "$STATUS_API_KEY" ]]; then
if [[ -n "$STATUS_API_URL" && -n "$STATUS_API_KEY" ]]; then

WP_PROJECT=$(echo "$HOSTNAME" | cut -d'-' -f1-2)
# Detect the PHP, WordPress, and Node.js versions
PHP_VERSION=$(php -v | head -n 1 | cut -d ' ' -f 2 | cut -d '.' -f 1,2)
WP_VERSION=$(wp core version --skip-plugins --skip-themes --skip-packages | cut -d '.' -f 1,2)
Expand All @@ -12,7 +11,6 @@ WP_VERSION=$(wp core version --skip-plugins --skip-themes --skip-packages | cut
JSON_PAYLOAD=$(cat <<EOF
{
"category": "wordpress",
"project": "$WP_PROJECT",
"domain": "$WP_FORCE_HOST",
"products": [
{
Expand All @@ -30,10 +28,16 @@ EOF
# echo $JSON_PAYLOAD
# Send the HTTP POST request with curl
curl -X POST \
-H "Content-Type: application/json" \
-H "x-api-key: $STATUS_API_KEY" \
-d "$JSON_PAYLOAD" \
"$STATUS_API_ENDPOINT"
--max-time 3 \
--retry 3 \
--retry-all-errors \
--retry-delay 3 \
--retry-max-time 18 \
-H "Content-Type: application/json" \
-H "x-api-key: $STATUS_API_KEY" \
-d "$JSON_PAYLOAD" \
"$STATUS_API_URL"
else
wp core version --extra
php -v
fi

0 comments on commit fbd26f9

Please sign in to comment.