-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from salihoglu87/master
PHP and Worpdress Version curl post to api if api env exist
- Loading branch information
Showing
1 changed file
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |