Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions .github/scripts/get_plugin_slug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,40 @@ done
# Get unique plugin names
UNIQUE_PLUGINS=($(printf '%s\n' "${PLUGINS[@]}" | sort -u))

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

# Output all valid plugins as JSON array for matrix strategy
if [ ${#VALID_PLUGINS[@]} -gt 0 ]; then
# Simple, reliable JSON array generation
PLUGINS_JSON="["
for i in "${!VALID_PLUGINS[@]}"; do
if [ $i -eq 0 ]; then
PLUGINS_JSON="$PLUGINS_JSON\"${VALID_PLUGINS[i]}\""
else
PLUGINS_JSON="$PLUGINS_JSON,\"${VALID_PLUGINS[i]}\""
fi
done
PLUGINS_JSON="$PLUGINS_JSON]"

echo "plugins=$PLUGINS_JSON" >> "$GITHUB_OUTPUT"
echo "has-plugins=true" >> "$GITHUB_OUTPUT"

# For backward compatibility, set slug to first plugin
PLUGIN_SLUG="${VALID_PLUGINS[0]}"
else
echo "plugins=[]" >> "$GITHUB_OUTPUT"
echo "has-plugins=false" >> "$GITHUB_OUTPUT"
PLUGIN_SLUG=""
fi

if [ -z "$PLUGIN_SLUG" ]; then
echo "No valid plugin directory found"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/update_composer_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ usage() {
echo " description - Optional: Package description (uses generic default if not provided)"
echo ""
echo "Examples:"
echo " $0 '0.0.2' 'https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.2/wp-graphql-webhooks.zip'"
echo " $0 '0.0.2' 'https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.2/wpgraphql-webhooks.zip'"
echo ""
echo " With custom package name and description:"
echo " $0 '0.0.5' 'https://example.com/plugin.zip' 'wpengine/my-plugin' 'My custom plugin description'"
Expand Down
53 changes: 40 additions & 13 deletions .github/workflows/plugin-artifact-for-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,68 @@ on:
- 'plugins/*/**.json'

jobs:
create-plugin-artifact:
name: Create Plugin Artifact
detect-plugins:
name: Detect Changed Plugins
runs-on: ubuntu-latest

outputs:
plugins: ${{ steps.plugin.outputs.plugins }}
has-plugins: ${{ steps.plugin.outputs.has-plugins }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get changed plugin directory
- name: Get changed plugin directories
id: plugin
run: |
bash .github/scripts/get_plugin_slug.sh \
${{ github.event.pull_request.base.sha }} \
${{ github.event.pull_request.head.sha }}

- name: Create plugin artifact
create-plugin-artifacts:
name: Create Plugin Artifacts
runs-on: ubuntu-latest
needs: detect-plugins
if: needs.detect-plugins.outputs.has-plugins == 'true'
strategy:
fail-fast: false
matrix:
plugin: ${{ fromJson(needs.detect-plugins.outputs.plugins) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create plugin artifact for ${{ matrix.plugin }}
uses: ./.github/actions/create-plugin-artifact
env:
PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }}
with:
slug: ${{ env.PLUGIN_SLUG }}
slug: ${{ matrix.plugin }}
composer-options: '--no-progress --optimize-autoloader --no-dev'

- name: Comment with artifact link
comment-on-pr:
name: Comment with Artifact Links
runs-on: ubuntu-latest
needs: [detect-plugins, create-plugin-artifacts]
if: needs.detect-plugins.outputs.has-plugins == 'true'
steps:
- name: Comment with artifact links
uses: actions/github-script@v7
env:
PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }}
PLUGINS: ${{ needs.detect-plugins.outputs.plugins }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const runId = context.runId;
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
const slug = process.env.PLUGIN_SLUG;
const body = `ℹ️ [Download the latest ${slug} plugin zip from this PR](${artifactUrl})\n<em>(See the 'Artifacts' section at the bottom)</em>`;
const plugins = JSON.parse(process.env.PLUGINS);

let body = '## 📦 Plugin Artifacts Ready!\n\n';
body += `[Download from GitHub Actions run](${artifactUrl})\n\n`;
body += '**Available plugins:**\n';
plugins.forEach(plugin => {
body += `- ✅ ${plugin}.zip\n`;
});
body += '\n<em>See the "Artifacts" section at the bottom of the Actions run page</em>';

// Find existing comment from this bot
const comments = await github.rest.issues.listComments({
Expand All @@ -55,7 +82,7 @@ jobs:
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.user.login === 'github-actions[bot]' &&
comment.body.includes(`ℹ️ [Download the latest ${slug} plugin zip from this PR]`)
comment.body.includes('## 📦 Plugin Artifacts Ready!')
);

if (botComment) {
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to/install-toolkit-plugins/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Copy and use this example as your `composer.json` for a typical WordPress projec
],
"require": {
"wpengine/hwp-previews": "*",
"wpengine/wp-graphql-webhooks": "*"
"wpengine/wpgraphql-webhooks": "*"
},
"config": {
"allow-plugins": {
Expand Down Expand Up @@ -57,7 +57,7 @@ Copy and use this example as your `composer.json` for a typical WordPress projec
To update to the latest version:

```bash
composer update wpengine/hwp-previews wpengine/wp-graphql-webhooks
composer update wpengine/hwp-previews wpengine/wpgraphql-webhooks
```

---
Expand Down
2 changes: 1 addition & 1 deletion plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WordPress plugins for the Headless WordPress Toolkit. Each plugin is paired with
| Plugin | Description |
|--------|-------------|
| [`hwp-previews`](./hwp-previews/README.md) | Headless Previews solution for WordPress: fully configurable preview URLs via the settings page which is framework agnostic. |
| [`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. |
| [`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. |


## Install
Expand Down
14 changes: 7 additions & 7 deletions plugins/composer-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@
}
}
},
"wpengine/wp-graphql-webhooks": {
"wpengine/wpgraphql-webhooks": {
"0.0.4": {
"name": "wpengine/wp-graphql-webhooks",
"name": "wpengine/wpgraphql-webhooks",
"version": "0.0.4",
"type": "wordpress-plugin",
"description": "Headless webhooks for WPGraphQL",
Expand All @@ -180,15 +180,15 @@
"email": "[email protected]"
},
"dist": {
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.4/wp-graphql-webhooks.zip",
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.4/wpgraphql-webhooks.zip",
"type": "zip"
},
"require": {
"composer/installers": "~1.0 || ~2.0"
}
},
"0.0.3": {
"name": "wpengine/wp-graphql-webhooks",
"name": "wpengine/wpgraphql-webhooks",
"version": "0.0.3",
"type": "wordpress-plugin",
"description": "Headless webhooks for WPGraphQL",
Expand All @@ -206,15 +206,15 @@
"email": "[email protected]"
},
"dist": {
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.3/wp-graphql-webhooks.zip",
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.3/wpgraphql-webhooks.zip",
"type": "zip"
},
"require": {
"composer/installers": "~1.0 || ~2.0"
}
},
"0.0.2": {
"name": "wpengine/wp-graphql-webhooks",
"name": "wpengine/wpgraphql-webhooks",
"version": "0.0.2",
"type": "wordpress-plugin",
"description": "Headless webhooks for WPGraphQL",
Expand All @@ -232,7 +232,7 @@
"email": "[email protected]"
},
"dist": {
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.2/wp-graphql-webhooks.zip",
"url": "https://github.com/wpengine/hwptoolkit/releases/download/%40wpengine%2Fwpgraphql-webhooks-wordpress-plugin-0.0.2/wpgraphql-webhooks.zip",
"type": "zip"
},
"require": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ setup_plugin() {
fi

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

cd "$ORIGINAL_PATH"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ WORDPRESS_DB_USER=${DB_USER}
WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
WORDPRESS_DB_NAME=${DB_NAME}

PLUGIN_SLUG=wp-graphql-webhooks
PLUGIN_SLUG=wpgraphql-webhooks
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/docs export-ignore
/phpstan export-ignore
/tests export-ignore
/wp-graphql-webhooks export-ignore
/wpgraphql-webhooks export-ignore

/.coveralls export-ignore
/.distignore export-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<description>Sniffs for the WPGraphQL plugin ecosystem </description>

<!-- What to scan: include any root-level PHP files, and the /src folder -->
<file>./wp-graphql-webhooks.php</file>
<file>./wpgraphql-webhooks.php</file>
<file>./activation.php</file>
<file>./deactivation.php</file>
<file>./src/</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ setup_file_permissions() {

setup_plugin() {
if [ "${SKIP_WP_SETUP}" = "true" ]; then
echo -e "$(warning_message "Skipping wp-graphql--webhooks installation...")"
echo -e "$(warning_message "Skipping wpgraphql--webhooks installation...")"
return 0
fi

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

cd "$ORIGINAL_PATH"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ else
echo -e "${YELLOW}⚠ readme.txt not found${NC}"
fi

# Update wp-graphql-webhooks.php
PLUGIN_FILE="wp-graphql-webhooks.php"
# Update wpgraphql-webhooks.php
PLUGIN_FILE="wpgraphql-webhooks.php"

if [ -f "$PLUGIN_FILE" ]; then
echo "Updating main plugin file: $PLUGIN_FILE..."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "wpengine/wp-graphql-webhooks",
"name": "wpengine/wpgraphql-webhooks",
"description": "Headless webhooks for WPGraphQL",
"type": "library",
"license": "GPL-2.0",
Expand Down Expand Up @@ -95,7 +95,7 @@
"php:psalm:fix": "psalm --alter"
},
"archive": {
"name": "wp-graphql-webhooks",
"name": "wpgraphql-webhooks",
"exclude": [
"/.*",
"/assets",
Expand Down
Loading