Skip to content

Build Plugin Zip

Build Plugin Zip #161

Workflow file for this run

name: Build Plugin Zip
on:
workflow_dispatch:
issue_comment:
types: [created]
jobs:
build:
name: "Build plugin zip"
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/build-zip')
)
steps:
- name: Check actions access
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.payload.comment.user.login
});
if (!['admin', 'maintain', 'write', 'triage'].includes(data.role_name)) {
core.setFailed(`User ${context.payload.comment.user.login} does not have actions access.`);
}
- name: Add reaction to command
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket'
});
- name: Get PR head ref
if: github.event_name == 'issue_comment'
id: pr
uses: actions/github-script@v7
with:
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
core.setOutput('ref', pr.head.ref);
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ steps.pr.outputs.ref || '' }}
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: './.nvmrc'
- name: Yarn install
run: yarn install
- name: "Grunt: create artifact"
run: grunt artifact
- name: Set timestamp
id: timestamp
run: echo "value=$(date +'%Y%m%d-%H%M%S')" >> "$GITHUB_OUTPUT"
- name: Rename artifact folder
run: mv artifact wordpress-seo
- name: Upload zip
uses: actions/upload-artifact@v4
with:
name: wordpress-seo-${{ steps.timestamp.outputs.value }}
path: wordpress-seo/
retention-days: 1
- name: Post artifact link
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `📦 Plugin zip built successfully!\n\nDownload it from the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
});