Skip to content

Commit

Permalink
Merge pull request #8 from salihoglu87/master
Browse files Browse the repository at this point in the history
PHP and Worpdress Version curl post to api if api env exist
  • Loading branch information
runningman84 authored Mar 9, 2023
2 parents e24557b + f82a6b9 commit 58ae002
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion report-versions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
#!/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

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)

wp core version --extra
# Set the JSON payload with versions and other info
JSON_PAYLOAD=$(cat <<EOF
{
"category": "wordpress",
"project": "$WP_PROJECT",
"domain": "$WP_FORCE_HOST",
"products": [
{
"name": "php",
"version": "$PHP_VERSION"
},
{
"name": "wordpress",
"version": "$WP_VERSION"
}
]
}
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"
else
wp core version --extra
fi

0 comments on commit 58ae002

Please sign in to comment.