Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional inputs don't work #3

Closed
jonnitto opened this issue Dec 2, 2020 · 14 comments
Closed

Optional inputs don't work #3

jonnitto opened this issue Dec 2, 2020 · 14 comments

Comments

@jonnitto
Copy link

jonnitto commented Dec 2, 2020

If I run the deploy command with optional input values, I get always the error Too many arguments, expected arguments "command" "stage".

If I run this command from my local machine, everything works fine.

This is my configuration

- name: Deploy website
  uses: deployphp/action@v1.0.5
  with:
    private-key: ${{ secrets.SSH_PRIVATE_KEY }}
    known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
    dep: deploy ${{ steps.extract-branch.outputs.branch }} --composer_auth '${{ env.composer_auth }}'

And this is in my PHP file:

use Symfony\Component\Console\Input\InputOption;

option('composer_auth', null, InputOption::VALUE_OPTIONAL, 'Add a composer authentification configuration');
@antonmedv
Copy link
Member

Difficult to tell what is wrong. Maybe it's some error with calling dep from nodejs:
https://github.com/deployphp/action/blob/master/index.js#L48

Also, please var_dump $argv from deploy.php file, lets print and see what the actual command is.

@jonnitto
Copy link
Author

jonnitto commented Dec 3, 2020

I think the main problem, is that the parameter contains spaces: http-basic.domain.tld user password. I wrote the task who uses this input to use URL decode so that I'm able to write http-basic.domain.tld+user+password. With this, it works. But now I can't (or at least I don't know how) replace the spaces with an + in the secret. (I need the secret also in another place with the spaces)

@jonnitto
Copy link
Author

jonnitto commented Dec 3, 2020

What do you mean with

Also, please var_dump $argv from deploy.php file, lets print and see what the actual command is.

Do you have a code example?

@antonmedv
Copy link
Member

var_dump($argv);

@jonnitto
Copy link
Author

jonnitto commented Dec 3, 2020

This is the output:

array(7) {
  [0] => string "bin/dep"
  [1] => string "deploy"
  [2] => string "staging"
  [3] => string "--composer_auth"
  [4] => string "'domain.tld"
  [5] => string "user"
  [6] => string"password'"
}

But it should be

array(7) {
  [0] => string "bin/dep"
  [1] => string "deploy"
  [2] => string "staging"
  [3] => string "--composer_auth"
  [4] => string "domain.tld user password"
}

This is what I get if I run the command dep deploy staging --composer_auth "domain.tld user password" in the CLI manually

@antonmedv
Copy link
Member

Yes, looks like there can be a better solution with correct splitting in js code. Will implement it.

@jonnitto
Copy link
Author

jonnitto commented Dec 3, 2020

In the meantime, I was able to able to change the secret dynamically like that:

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    env:
      composer_auth: ${{ secrets.COMPOSER_AUTH }}
    steps:
      - name: Set environment variables
        run: |
          echo "composer_auth_deployer=${composer_auth//' '/'+'}" >> $GITHUB_ENV
      # Do all the checkout, building, etc...
      - name: Deploy website
        uses: deployphp/action@v1.0.5
        with:
          private-key: ${{ secrets.SSH_PRIVATE_KEY }}
          known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
          dep: deploy ${{ env.stage }} --composer_auth ${{ env.composer_auth_deployer }}

and in the PHP:

if (input()->hasOption('composer_auth')) {
    $config = input()->getOption('composer_auth');
    if ($config) {
        cd('{{release_path}}');
        run('{{bin/composer}} config --auth ' . urldecode($config));
    }
}

But of course, it would be much nicer if I could use composer_auth directly.

@antonmedv
Copy link
Member

Released v1.0.6. Please test it.

@jonnitto
Copy link
Author

jonnitto commented Dec 4, 2020

With 1.0.6 I'll following error:

internal/modules/cjs/loader.js:800
    throw err;
    ^

Error: Cannot find module 'argv-split'
Require stack:
- /home/runner/work/_actions/deployphp/action/v1.0.6/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/work/_actions/deployphp/action/v1.0.6/index.js:4:15)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/runner/work/_actions/deployphp/action/v1.0.6/index.js' ]
}

@antonmedv
Copy link
Member

This is strange. Will fix it.

@jonnitto
Copy link
Author

jonnitto commented Dec 4, 2020

If you made the commit, I can make a test against @master

@antonmedv
Copy link
Member

Release a fix in v1.0.7

@antonmedv
Copy link
Member

Is it fixed?

@jonnitto
Copy link
Author

Yeah, it works now as expected, thank you a lot 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants