diff --git a/.github/workflows/deploy-standalone-plugins.yml b/.github/workflows/deploy-standalone-plugins.yml index 287f35f04d..c0cd3ebc24 100644 --- a/.github/workflows/deploy-standalone-plugins.yml +++ b/.github/workflows/deploy-standalone-plugins.yml @@ -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 @@ -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 @@ -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 @@ -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 }}