Skip to content

Commit 003b166

Browse files
authored
Merge pull request #232 from wpengine/chore-create-github-workflow-release-plugins
chore: Added workflow for Plugin PRs to create zip for testing
2 parents 4388b4e + 743f891 commit 003b166

6 files changed

Lines changed: 102 additions & 11 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'Create Plugin Artifact'
2+
description: 'Builds and uploads a plugin artifact for a PR if a plugin directory is modified.'
3+
inputs:
4+
slug:
5+
description: 'Plugin slug (directory name under plugins/)'
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Set up PHP
11+
uses: shivammathur/setup-php@v2
12+
with:
13+
php-version: '7.4'
14+
15+
- name: Install dependencies and build
16+
working-directory: plugins/${{ inputs.slug }}
17+
run: |
18+
composer install --no-dev --optimize-autoloader
19+
echo "${GITHUB_SHA}" > build-sha.txt
20+
rm -f plugin-build/${{ inputs.slug }}-*.zip
21+
composer archive -vvv --format=zip --file="plugin-build/${{ inputs.slug }}" --dir="."
22+
shell: bash
23+
24+
- name: Upload plugin artifact
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: ${{ inputs.slug }}
28+
path: plugins/${{ inputs.slug }}/plugin-build/*.zip
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Plugin Artifact for PR
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'plugins/**'
7+
8+
jobs:
9+
create-plugin-artifact:
10+
name: Create Plugin Artifact
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Get changed plugin directory
18+
id: plugin
19+
run: |
20+
git fetch --prune --unshallow
21+
plugin=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^plugins/' | head -1 | cut -d/ -f2)
22+
echo "slug=$plugin" >> $GITHUB_OUTPUT
23+
24+
- name: Create plugin artifact
25+
uses: ./.github/actions/create-plugin-artifact
26+
env:
27+
PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }}
28+
with:
29+
slug: ${{ env.PLUGIN_SLUG }}
30+
31+
- name: Comment with artifact link
32+
uses: actions/github-script@v7
33+
env:
34+
PLUGIN_SLUG: ${{ steps.plugin.outputs.slug }}
35+
with:
36+
github-token: ${{ secrets.GITHUB_TOKEN }}
37+
script: |
38+
const pr = context.payload.pull_request;
39+
const runId = context.runId;
40+
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
41+
const slug = process.env.PLUGIN_SLUG;
42+
const body = `ℹ️ [Download the ${slug} plugin artifact from this workflow run](${artifactUrl}) (see the 'Artifacts' section at the bottom).`;
43+
await github.rest.issues.createComment({
44+
issue_number: pr.number,
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
body
48+
});

plugins/hwp-previews/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# HWP Previews
2+
3+
## 0.0.1
4+
5+
- Proof of concept.

plugins/hwp-previews/composer.json

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,27 @@
5050
}
5151
},
5252
"archive": {
53+
"name": "hwp-previews",
5354
"exclude": [
54-
"vendor/",
55-
"phpcs/",
56-
"phpstan/",
57-
".gitignore",
58-
".editorconfig",
59-
"composer.json",
60-
"composer.lock",
61-
"*.xml",
62-
"*.dist",
63-
"*.md"
55+
"/.*",
56+
"bin",
57+
"docker",
58+
"docs",
59+
"phpstan",
60+
"phpcs",
61+
"plugin-build",
62+
"tests",
63+
"!vendor",
64+
"!vendor-prefixed",
65+
"/docker-compose.yml",
66+
"/phpstan.neon.dist",
67+
"/psalm.xml",
68+
"/phpcs.xml",
69+
"/ACTIONS_AND_FILTERS.md",
70+
"/phpcs-cache.json",
71+
"/Thumbs.db",
72+
"/auth.json",
73+
"/.DS_Store"
6474
]
6575
},
6676
"autoload": {

plugins/hwp-previews/composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/hwp-previews/docs/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)