Skip to content
name: Deploy standalone plugins to WordPress.org
on:
release:
types: [published]
workflow_dispatch:
inputs:
slug:
type: string
description: 'The slug of the plugin to deploy'
dry-run:
type: boolean
description: 'Debug mode (run without publishing).'
default: false
jobs:
release:
name: Prepare Deployment
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install npm dependencies
run: npm ci
- name: Get plugin version
id: get-version
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "version=$(node ./bin/plugin/cli.js get-plugin-version --slug=${{ inputs.slug }})" >> $GITHUB_OUTPUT
- name: Set matrix
id: set-matrix
run: |
if ${{ github.event_name == 'workflow_dispatch' }}; then
result=$(echo "${{ steps.get-version.outputs.version }}" | awk '/^(\*|[0-9]+(\.[0-9]+){0,2}(-[a-zA-Z0-9.]+)?)$/ {print "Matched"}')
if [[ -n "$result" ]]; then
# Set the manual input values in JSON format for use in the matrix.
echo "matrix={\"include\":[{\"slug\":\"${{ inputs.slug }}\",\"version\":\"${{ steps.get-version.outputs.version }}\",\"dry-run\":\"${{ inputs.dry-run }}\"}]}" >> $GITHUB_OUTPUT
else
echo "The ${{ inputs.slug }} module slug is missing in the file plugins.json."
exit 1
fi
else
# Load the JSON file and parse from "{name: {slug, version}, ...}" to "include: [{ name, slug, version }, ...]"
# for use in the matrix.
# The "dry-run" parameter is included here to set the deployment mode.
# When running the manual (workflow_dispatch) workflow, this value will be set from manual input type.
echo "matrix="$(jq -c '{include:[keys[] as $k | {name:$k,slug:.[$k].slug,version:.[$k].version,"dry-run":false }]}' plugins.json) >> $GITHUB_OUTPUT
fi
deploy:
name: Deploy Plugin
needs: release
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.release.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install npm dependencies
run: npm ci
- name: Building standalone plugins
run: npm run build-plugins
- name: Deploy Standalone Plugin - ${{ matrix.slug }}
uses: 10up/action-wordpress-plugin-deploy@stable
with:
dry-run: ${{ matrix.dry-run }}
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: ${{ matrix.slug }}
VERSION: ${{ matrix.version }}
BUILD_DIR: ./build/${{ matrix.slug }}
ASSETS_DIR: ./build/${{ matrix.slug }}/.wordpress-org