Skip to content

chore: Internal Testing & Validation WPGraphQL Logging Plugin #487

chore: Internal Testing & Validation WPGraphQL Logging Plugin

chore: Internal Testing & Validation WPGraphQL Logging Plugin #487

name: Plugin Artifact for PR
on:
pull_request:
paths:
- 'plugins/*/**.php'
- 'plugins/*/**.js'
- 'plugins/*/**.css'
- 'plugins/*/**.json'
jobs:
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 directories
id: plugin
run: |
bash .github/scripts/get_plugin_slug.sh \
${{ github.event.pull_request.base.sha }} \
${{ github.event.pull_request.head.sha }}
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
with:
slug: ${{ matrix.plugin }}
composer-options: '--no-progress --optimize-autoloader --no-dev'
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:
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 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({
issue_number: pr.number,
owner: context.repo.owner,
repo: context.repo.repo
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('## 📦 Plugin Artifacts Ready!')
);
if (botComment) {
// Update existing comment
core.info(`Updating existing comment with ID: ${botComment.id}`);
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
} else {
// Create new comment
await github.rest.issues.createComment({
issue_number: pr.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
}