-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ghost-inspector.yml
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Ghost Inspector | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
env: | ||
PLUGIN_SLUG: kadence-blocks | ||
WP_URL: ${{ secrets.WP_URL }} | ||
GI_API_KEY: ${{ secrets.GHOST_INSPECTOR_API_KEY }} | ||
GI_SUITE_ID: ${{ secrets.GHOST_INSPECTOR_SUITE_ID }} | ||
WP_API_KEY: ${{ secrets.WP_PLUGIN_API_KEY }} | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Composer | ||
run: composer config -g github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }} | ||
|
||
- name: Build plugin | ||
run: | | ||
npm install --legacy-peer-deps | ||
npm run build | ||
npm install --legacy-peer-deps | ||
npm run build | ||
- name: Create plugin archive | ||
run: | | ||
zip -r ${{ env.PLUGIN_SLUG }}.zip . \ | ||
-x "*.git*" "*.github*" "tests*" "src*" "node_modules*" "*.gitignore" | ||
- name: Upload plugin | ||
run: | | ||
# Upload plugin using the working format | ||
UPLOAD_RESPONSE=$(curl -X POST \ | ||
-H "X-API-Key: ${{ env.WP_API_KEY }}" \ | ||
-F "plugin_zip=@${{ env.PLUGIN_SLUG }}.zip" \ | ||
-F "plugin_zip=@${{ env.PLUGIN_SLUG }}.zip;type=application/zip" \ | ||
-s \ | ||
"${{ env.WP_URL }}/wp-json/plugin-upload/v1/upload") | ||
echo "Upload response: $UPLOAD_RESPONSE" | ||
# Check if the request was successful using grep like the shell script | ||
if echo "$UPLOAD_RESPONSE" | grep -q '"success":true'; then | ||
echo "Plugin uploaded successfully!" | ||
PLUGIN_DIR=$(echo "$UPLOAD_RESPONSE" | grep -o '"plugin_directory":"[^"]*"' | cut -d'"' -f4) | ||
echo "Installed in directory: $PLUGIN_DIR" | ||
else | ||
echo "Failed to upload plugin" | ||
echo "$UPLOAD_RESPONSE" | grep -o '"message":"[^"]*"' | cut -d'"' -f4 | ||
exit 1 | ||
fi | ||
- name: Run Ghost Inspector tests | ||
run: | | ||
RESPONSE=$(curl -s "https://api.ghostinspector.com/v1/suites/${{ env.GI_SUITE_ID }}/execute/?apiKey=${{ env.GI_API_KEY }}") | ||
echo "Ghost Inspector response: $RESPONSE" | ||
# Check if the tests were triggered successfully | ||
if ! echo "$RESPONSE" | jq -e '.code == "SUCCESS"' > /dev/null; then | ||
echo "Failed to trigger Ghost Inspector tests" | ||
exit 1 | ||
fi | ||
- name: Run Ghost Inspector tests | ||
run: | | ||
RESPONSE=$(curl -s "https://api.ghostinspector.com/v1/suites/${{ env.GI_SUITE_ID }}/execute/?apiKey=${{ env.GI_API_KEY }}") | ||
echo "Ghost Inspector response: $RESPONSE" | ||
# Check if the tests were triggered successfully | ||
if ! echo "$RESPONSE" | jq -e '.code == "SUCCESS"' > /dev/null; then | ||
echo "Failed to trigger Ghost Inspector tests" | ||
exit 1 | ||
fi |