Skip to content

Commit b0fd0f7

Browse files
authored
Merge pull request #386 from wpengine/rename-wp-graphql-webhooks-fix
fix(wpgraphql-webhooks): resolve installation failure from naming inc…
2 parents 1bd514b + 357c7ee commit b0fd0f7

File tree

11 files changed

+100
-49
lines changed

11 files changed

+100
-49
lines changed

.github/scripts/get_plugin_slug.sh

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,40 @@ done
2929
# Get unique plugin names
3030
UNIQUE_PLUGINS=($(printf '%s\n' "${PLUGINS[@]}" | sort -u))
3131

32-
# Find the first plugin that actually exists
33-
PLUGIN_SLUG=""
32+
# Find all valid plugins that have changes
33+
VALID_PLUGINS=()
3434
for plugin in "${UNIQUE_PLUGINS[@]}"; do
35-
if [ -d "plugins/$plugin" ] || [[ " ${CHANGED_FILES[@]} " =~ "plugins/$plugin/" ]]; then
36-
PLUGIN_SLUG="$plugin"
37-
echo "Found plugin in changes or directory: $PLUGIN_SLUG"
38-
break
35+
if [ -d "plugins/$plugin" ]; then
36+
count=$(printf '%s\n' "${PLUGINS[@]}" | grep -c "^$plugin$")
37+
VALID_PLUGINS+=("$plugin")
38+
echo "Found plugin with $count changes: $plugin"
3939
fi
4040
done
4141

42+
# Output all valid plugins as JSON array for matrix strategy
43+
if [ ${#VALID_PLUGINS[@]} -gt 0 ]; then
44+
# Simple, reliable JSON array generation
45+
PLUGINS_JSON="["
46+
for i in "${!VALID_PLUGINS[@]}"; do
47+
if [ $i -eq 0 ]; then
48+
PLUGINS_JSON="$PLUGINS_JSON\"${VALID_PLUGINS[i]}\""
49+
else
50+
PLUGINS_JSON="$PLUGINS_JSON,\"${VALID_PLUGINS[i]}\""
51+
fi
52+
done
53+
PLUGINS_JSON="$PLUGINS_JSON]"
54+
55+
echo "plugins=$PLUGINS_JSON" >> "$GITHUB_OUTPUT"
56+
echo "has-plugins=true" >> "$GITHUB_OUTPUT"
57+
58+
# For backward compatibility, set slug to first plugin
59+
PLUGIN_SLUG="${VALID_PLUGINS[0]}"
60+
else
61+
echo "plugins=[]" >> "$GITHUB_OUTPUT"
62+
echo "has-plugins=false" >> "$GITHUB_OUTPUT"
63+
PLUGIN_SLUG=""
64+
fi
65+
4266
if [ -z "$PLUGIN_SLUG" ]; then
4367
echo "No valid plugin directory found"
4468
exit 1

.github/scripts/update_composer_package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ usage() {
1818
echo " description - Optional: Package description (uses generic default if not provided)"
1919
echo ""
2020
echo "Examples:"
21-
echo " $0 '0.0.2' 'https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.2/wp-graphql-webhooks.zip'"
21+
echo " $0 '0.0.2' 'https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.2/wpgraphql-webhooks.zip'"
2222
echo ""
2323
echo " With custom package name and description:"
2424
echo " $0 '0.0.5' 'https://example.com/plugin.zip' 'wpengine/my-plugin' 'My custom plugin description'"

.github/workflows/plugin-artifact-for-pr.yml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,68 @@ on:
99
- 'plugins/*/**.json'
1010

1111
jobs:
12-
create-plugin-artifact:
13-
name: Create Plugin Artifact
12+
detect-plugins:
13+
name: Detect Changed Plugins
1414
runs-on: ubuntu-latest
15-
15+
outputs:
16+
plugins: ${{ steps.plugin.outputs.plugins }}
17+
has-plugins: ${{ steps.plugin.outputs.has-plugins }}
1618
steps:
1719
- name: Checkout
1820
uses: actions/checkout@v4
1921

20-
- name: Get changed plugin directory
22+
- name: Get changed plugin directories
2123
id: plugin
2224
run: |
2325
bash .github/scripts/get_plugin_slug.sh \
2426
${{ github.event.pull_request.base.sha }} \
2527
${{ github.event.pull_request.head.sha }}
2628
27-
- name: Create plugin artifact
29+
create-plugin-artifacts:
30+
name: Create Plugin Artifacts
31+
runs-on: ubuntu-latest
32+
needs: detect-plugins
33+
if: needs.detect-plugins.outputs.has-plugins == 'true'
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
plugin: ${{ fromJson(needs.detect-plugins.outputs.plugins) }}
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Create plugin artifact for ${{ matrix.plugin }}
2844
uses: ./.github/actions/create-plugin-artifact
29-
env:
30-
PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }}
3145
with:
32-
slug: ${{ env.PLUGIN_SLUG }}
46+
slug: ${{ matrix.plugin }}
3347
composer-options: '--no-progress --optimize-autoloader --no-dev'
3448

35-
- name: Comment with artifact link
49+
comment-on-pr:
50+
name: Comment with Artifact Links
51+
runs-on: ubuntu-latest
52+
needs: [detect-plugins, create-plugin-artifacts]
53+
if: needs.detect-plugins.outputs.has-plugins == 'true'
54+
steps:
55+
- name: Comment with artifact links
3656
uses: actions/github-script@v7
3757
env:
38-
PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }}
58+
PLUGINS: ${{ needs.detect-plugins.outputs.plugins }}
3959
with:
4060
github-token: ${{ secrets.GITHUB_TOKEN }}
4161
script: |
4262
const pr = context.payload.pull_request;
4363
const runId = context.runId;
4464
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
45-
const slug = process.env.PLUGIN_SLUG;
46-
const body = `ℹ️ [Download the latest ${slug} plugin zip from this PR](${artifactUrl})\n<em>(See the 'Artifacts' section at the bottom)</em>`;
65+
const plugins = JSON.parse(process.env.PLUGINS);
66+
67+
let body = '## 📦 Plugin Artifacts Ready!\n\n';
68+
body += `[Download from GitHub Actions run](${artifactUrl})\n\n`;
69+
body += '**Available plugins:**\n';
70+
plugins.forEach(plugin => {
71+
body += `- ✅ ${plugin}.zip\n`;
72+
});
73+
body += '\n<em>See the "Artifacts" section at the bottom of the Actions run page</em>';
4774
4875
// Find existing comment from this bot
4976
const comments = await github.rest.issues.listComments({
@@ -55,7 +82,7 @@ jobs:
5582
const botComment = comments.data.find(comment =>
5683
comment.user.type === 'Bot' &&
5784
comment.user.login === 'github-actions[bot]' &&
58-
comment.body.includes(`ℹ️ [Download the latest ${slug} plugin zip from this PR]`)
85+
comment.body.includes('## 📦 Plugin Artifacts Ready!')
5986
);
6087
6188
if (botComment) {

docs/how-to/install-toolkit-plugins/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Copy and use this example as your `composer.json` for a typical WordPress projec
2626
],
2727
"require": {
2828
"wpengine/hwp-previews": "*",
29-
"wpengine/wp-graphql-webhooks": "*"
29+
"wpengine/wpgraphql-webhooks": "*"
3030
},
3131
"config": {
3232
"allow-plugins": {
@@ -57,7 +57,7 @@ Copy and use this example as your `composer.json` for a typical WordPress projec
5757
To update to the latest version:
5858

5959
```bash
60-
composer update wpengine/hwp-previews wpengine/wp-graphql-webhooks
60+
composer update wpengine/hwp-previews wpengine/wpgraphql-webhooks
6161
```
6262

6363
---

plugins/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ WordPress plugins for the Headless WordPress Toolkit. Each plugin is paired with
77
| Plugin | Description |
88
|--------|-------------|
99
| [`hwp-previews`](./hwp-previews/README.md) | Headless Previews solution for WordPress: fully configurable preview URLs via the settings page which is framework agnostic. |
10-
| [`wp-graphql-webhooks`](./wp-graphql-webhooks/README.md) | A WordPress plugin that extends [WPGraphQL](https://www.wpgraphql.com/) to support webhook subscriptions and dispatching for headless WordPress environments. This allows external applications to listen and respond to WordPress content changes through GraphQL-driven webhook events. |
10+
| [`wpgraphql-webhooks`](./wpgraphql-webhooks/README.md) | A WordPress plugin that extends [WPGraphQL](https://www.wpgraphql.com/) to support webhook subscriptions and dispatching for headless WordPress environments. This allows external applications to listen and respond to WordPress content changes through GraphQL-driven webhook events. |
1111

1212

1313
## Install

plugins/composer-packages.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@
160160
}
161161
}
162162
},
163-
"wpengine/wp-graphql-webhooks": {
163+
"wpengine/wpgraphql-webhooks": {
164164
"0.0.4": {
165-
"name": "wpengine/wp-graphql-webhooks",
165+
"name": "wpengine/wpgraphql-webhooks",
166166
"version": "0.0.4",
167167
"type": "wordpress-plugin",
168168
"description": "Headless webhooks for WPGraphQL",
@@ -180,15 +180,15 @@
180180
"email": "[email protected]"
181181
},
182182
"dist": {
183-
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.4/wp-graphql-webhooks.zip",
183+
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.4/wpgraphql-webhooks.zip",
184184
"type": "zip"
185185
},
186186
"require": {
187187
"composer/installers": "~1.0 || ~2.0"
188188
}
189189
},
190190
"0.0.3": {
191-
"name": "wpengine/wp-graphql-webhooks",
191+
"name": "wpengine/wpgraphql-webhooks",
192192
"version": "0.0.3",
193193
"type": "wordpress-plugin",
194194
"description": "Headless webhooks for WPGraphQL",
@@ -206,15 +206,15 @@
206206
"email": "[email protected]"
207207
},
208208
"dist": {
209-
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.3/wp-graphql-webhooks.zip",
209+
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.3/wpgraphql-webhooks.zip",
210210
"type": "zip"
211211
},
212212
"require": {
213213
"composer/installers": "~1.0 || ~2.0"
214214
}
215215
},
216216
"0.0.2": {
217-
"name": "wpengine/wp-graphql-webhooks",
217+
"name": "wpengine/wpgraphql-webhooks",
218218
"version": "0.0.2",
219219
"type": "wordpress-plugin",
220220
"description": "Headless webhooks for WPGraphQL",
@@ -232,7 +232,7 @@
232232
"email": "[email protected]"
233233
},
234234
"dist": {
235-
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.2/wp-graphql-webhooks.zip",
235+
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.2/wpgraphql-webhooks.zip",
236236
"type": "zip"
237237
},
238238
"require": {

plugins/wpgraphql-debug-extensions/bin/install-test-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ setup_plugin() {
149149
fi
150150

151151
# Add this repo as a plugin to the repo
152-
if [ ! -d $WORDPRESS_ROOT_DIR/wp-content/plugins/wp-graphql-webhooks ]; then
152+
if [ ! -d $WORDPRESS_ROOT_DIR/wp-content/plugins/wpgraphql-webhooks ]; then
153153
echo -e "$(status_message "Symlinking the plugin to the WordPress plugins directory...")"
154154

155155
cd "$ORIGINAL_PATH"

plugins/wpgraphql-webhooks/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"php:psalm:fix": "psalm --alter"
9696
},
9797
"archive": {
98-
"name": "wp-graphql-webhooks",
98+
"name": "wpgraphql-webhooks",
9999
"exclude": [
100100
"/.*",
101101
"/assets",

plugins/wpgraphql-webhooks/src/Admin/WebhooksListTable.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function __construct( WebhookRepository $repository ) {
3535
$this->repository = $repository;
3636

3737
parent::__construct( [
38-
'singular' => __( 'Webhook', 'wp-graphql-webhooks' ),
39-
'plural' => __( 'Webhooks', 'wp-graphql-webhooks' ),
38+
'singular' => __( 'Webhook', 'graphql-webhooks' ),
39+
'plural' => __( 'Webhooks', 'graphql-webhooks' ),
4040
'ajax' => false,
4141
] );
4242
}
@@ -49,11 +49,11 @@ public function __construct( WebhookRepository $repository ) {
4949
public function get_columns() {
5050
return [
5151
'cb' => '<input type="checkbox" />',
52-
'name' => __( 'Name', 'wp-graphql-webhooks' ),
53-
'event' => __( 'Event', 'wp-graphql-webhooks' ),
54-
'method' => __( 'Method', 'wp-graphql-webhooks' ),
55-
'url' => __( 'URL', 'wp-graphql-webhooks' ),
56-
'headers' => __( 'Headers', 'wp-graphql-webhooks' ),
52+
'name' => __( 'Name', 'graphql-webhooks' ),
53+
'event' => __( 'Event', 'graphql-webhooks' ),
54+
'method' => __( 'Method', 'graphql-webhooks' ),
55+
'url' => __( 'URL', 'graphql-webhooks' ),
56+
'headers' => __( 'Headers', 'graphql-webhooks' ),
5757
];
5858
}
5959

@@ -77,7 +77,7 @@ public function get_sortable_columns() {
7777
*/
7878
public function get_bulk_actions() {
7979
return [
80-
'delete' => __( 'Delete', 'wp-graphql-webhooks' ),
80+
'delete' => __( 'Delete', 'graphql-webhooks' ),
8181
];
8282
}
8383

@@ -93,12 +93,12 @@ public function process_bulk_action() {
9393

9494
// Verify nonce
9595
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'bulk-' . $this->_args['plural'] ) ) {
96-
wp_die( esc_html__( 'Security check failed.', 'wp-graphql-webhooks' ) );
96+
wp_die( esc_html__( 'Security check failed.', 'graphql-webhooks' ) );
9797
}
9898

9999
// Check permissions
100100
if ( ! current_user_can( 'manage_options' ) ) {
101-
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wp-graphql-webhooks' ) );
101+
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'graphql-webhooks' ) );
102102
}
103103

104104
// Get selected webhooks
@@ -194,7 +194,7 @@ public function column_default( $item, $column_name ) {
194194
return '<span class="webhook-method">' . esc_html( $item->method ) . '</span>';
195195
case 'headers':
196196
$count = is_array( $item->headers ) ? count( $item->headers ) : 0;
197-
return $count > 0 ? sprintf( __( '%d headers', 'wp-graphql-webhooks' ), $count ) : '';
197+
return $count > 0 ? sprintf( __( '%d headers', 'graphql-webhooks' ), $count ) : '';
198198
default:
199199
return '';
200200
}
@@ -236,9 +236,9 @@ public function column_name( $item ) {
236236
);
237237

238238
$actions = [
239-
'edit' => sprintf( '<a href="%s">%s</a>', esc_url( $edit_url ), __( 'Edit', 'wp-graphql-webhooks' ) ),
240-
'test' => sprintf( '<a href="#" class="test-webhook" data-webhook-id="%d">%s</a>', $item->id, __( 'Test', 'wp-graphql-webhooks' ) ),
241-
'delete' => sprintf( '<a href="%s" class="submitdelete">%s</a>', esc_url( $delete_url ), __( 'Delete', 'wp-graphql-webhooks' ) ),
239+
'edit' => sprintf( '<a href="%s">%s</a>', esc_url( $edit_url ), __( 'Edit', 'graphql-webhooks' ) ),
240+
'test' => sprintf( '<a href="#" class="test-webhook" data-webhook-id="%d">%s</a>', $item->id, __( 'Test', 'graphql-webhooks' ) ),
241+
'delete' => sprintf( '<a href="%s" class="submitdelete">%s</a>', esc_url( $delete_url ), __( 'Delete', 'graphql-webhooks' ) ),
242242
];
243243

244244
return sprintf(
@@ -253,7 +253,7 @@ public function column_name( $item ) {
253253
* Display when no items
254254
*/
255255
public function no_items() {
256-
esc_html_e( 'No webhooks found.', 'wp-graphql-webhooks' );
256+
esc_html_e( 'No webhooks found.', 'graphql-webhooks' );
257257
}
258258

259259
/**

plugins/wpgraphql-webhooks/wpgraphql-webhooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Author URI: https://github.com/wpengine
99
* Update URI: https://github.com/wpengine/hwptoolkit
1010
* Version: 0.0.4
11-
* Text Domain: wpgraphql-webhooks
11+
* Text Domain: graphql-webhooks
1212
* Domain Path: /languages
1313
* Requires at least: 6.0
1414
* Tested up to: 6.8

0 commit comments

Comments
 (0)