forcedotcom / salesforcedx-actions

(Unofficial) GitHub Actions for SalesforceDX using the Salesforce CLI
BSD 3-Clause "New" or "Revised" License
38 stars 32 forks source link

force:source:deploy not respecting double quotes in args #1

Open Clint-Chester opened 4 years ago

Clint-Chester commented 4 years ago

Issue

I am trying to use the force:source:deploy by providing a comma separated list of file paths in which some of the file names have spaces. However when passing the double quotes in the args, I'm getting sfdx errors with unrecognized file paths due to the file name being chopped off.

Steps to reproduce

The step below assumes that authentication, default user names and GitHub outputs have been setup correctly. The following is an example of the deploy step.

- name: Deploy files
  uses: forcedotcom/salesforcedx-actions@master
    with:
      args: 'force:source:deploy -p "${{ steps.files.outputs.files-to-deploy }}" -u ${{ secrets.SALESFORCE_USERNAME }}'

This is the files-to-deploy variable

force-app/main/default/layouts/Contact-Contact Layout.layout-meta.xml, force-app/main/default/objects/Contact/Contact.object-meta.xml

Expected Outcome

Files deploy correctly to target environment. Confirmed this by doing a direct npm install with the sfdx-cli and not using the docker action.

Actual Outcome

Following is the output received.

ERROR running force:source:deploy:  Unexpected arguments: Layout.layout-meta.xml,, force-app/main/default/objects/Contact/Contact.object-meta.xml

If I'm passing in the arguments incorrectly that would be an ideal news story 😄 any help is greatly appreciated. Thanks!

Rickvlaar commented 4 years ago

Hi Clint,

Took my a while figure this out, but the reason the quotes are not respected is because it is passed through multiple shells, each with their own rules for escaping strings. In the end the fix was simple. You have to add escape single qoutes around the variable enclosed in double qoutes.

args: 'force:source:deploy -c -l RunLocalTests -p ''"${{ env.files_to_deploy }}"'' -u ***

shanerk commented 4 years ago

I am calling this directly as follows:

sfdx force:source:deploy -u [ORG] -p "force-app/main/default/layouts/Snapshot__mdt-Snapshot Layout.layout-meta.xml"

And using the escaped single quote method above didn't solve it for me. Any advice?

Rickvlaar commented 4 years ago

I would be glad to help, I've spent to much energy figuring out this mess myself. could you maybe share the entire file? (Redacted for privacy of course)