Skip to content

Commit

Permalink
Update manual workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mukeshpanchal27 committed Feb 19, 2024
1 parent 2841611 commit 2a0c800
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/deploy-standalone-plugins.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Deploy standalone plugins to WordPress.org

on:
# TODO The pull_request will be removed once the workflow is tested.
pull_request:
branches:
- trunk
Expand Down Expand Up @@ -48,17 +49,18 @@ jobs:
id: get-version
if: ${{ github.event_name == 'workflow_dispatch' && steps.get-plugin-directory.outputs.directory == 'build' }}
run: |
if [[ ${{ steps.get-type.outputs.type }} == 'module' ]]; then
echo "version=$(node ./bin/plugin/cli.js get-plugin-version --slug=${{ inputs.slug }})" >> $GITHUB_OUTPUT
fi
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 }}\",,\"directory\":\"${{ steps.get-plugin-directory.outputs.directory }}\",\"dry-run\":\"${{ inputs.dry-run }}\"}]}" >> $GITHUB_OUTPUT
if ${{ steps.get-plugin-directory.outputs.directory == 'plugins' }}; then
# Set the manual input values in JSON format for use in the matrix for plugins.
echo "matrix={\"include\":[{\"slug\":\"${{ inputs.slug }}\",\"directory\":\"${{ steps.get-plugin-directory.outputs.directory }}\",\"dry-run\":\"true\"}]}" >> $GITHUB_OUTPUT
elif [[ -n "$result" ]]; then
# Set the manual input values in JSON format for use in the matrix for modules.
echo "matrix={\"include\":[{\"slug\":\"${{ inputs.slug }}\",\"version\":\"${{ steps.get-version.outputs.version }}\",\"directory\":\"${{ steps.get-plugin-directory.outputs.directory }}\",\"dry-run\":\"true\"}]}" >> $GITHUB_OUTPUT
else
echo "The ${{ inputs.slug }} module slug is missing in the file plugins.json."
exit 1
Expand All @@ -68,7 +70,7 @@ jobs:
# 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: ([.modules | to_entries[] | {name:.key,slug:.value.slug,version:.value.version,directory:"build","dry-run":false }] + [.plugins[] | {slug:. , directory:"plugins", "dry-run":false}])}' plugins.json)" >> $GITHUB_OUTPUT
echo "matrix=$(jq -c '{include: ([.modules | to_entries[] | {name:.key,slug:.value.slug,version:.value.version,directory:"build","dry-run":true }] + [.plugins[] | {slug:. , directory:"plugins", "dry-run":true}])}' plugins.json)" >> $GITHUB_OUTPUT
fi
deploy:
name: Deploy Plugin
Expand All @@ -93,8 +95,12 @@ jobs:
with:
dry-run: ${{ matrix.dry-run }}
env:
# TODO Once the workflow is tested, we will remove the comment and use the secret SVN access.
#SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
#SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
# TODO Once the workflow is tested, we will remove this test credential.
SVN_PASSWORD: SVN_PASSWORD
SVN_USERNAME: SVN_USERNAME
SLUG: ${{ matrix.slug }}
VERSION: ${{ matrix.version }}
BUILD_DIR: ./${{ matrix.directory }}/${{ matrix.slug }}
Expand Down

0 comments on commit 2a0c800

Please sign in to comment.