Closed AdeelK93 closed 6 months ago
I believe you need to quote your command, same as in your shell:
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@v2
with:
job: test
region: us-east1
flags: --command="python --args=-m,job.main"
quoting like that results in the command "python --args=-m,job.main"
- but the command and args are distinct components of the cloud run api
@sethvargo Looking through past issues, it looks like this issue was created twice before (#58 and #444) - but both times the issue was closed. This is a legitimate issue!
What is the equivalent gcloud
command for what you're trying to do?
so a gcloud command that i can run that would behave correctly would look like:
gcloud run jobs deploy test ... --command=python --args=-m,job.main
and when i use this GHA - i delimit using =
. However, the GHA replaces the =
with spaces, resulting in this invalid command:
gcloud run jobs deploy test ... --command python --args -m,job.main
which is effectively a shell syntax issue due to this character replacement by the GHA
thank you Seth
Is the issue specifically because the args start with a dash (-m
)?
correct. if the arg had a dash anywhere but the beginning, this wouldn't be an issue. specifically because a space was used instead of an =
Can you try:
flags: --command=python "--args=-m,job.main"
If that doesn't work, please provide the debug logs so I can see the exact command that's being executed.
The reason this is difficult is because we don't actually know the flags gcloud is expecting, so it's impossible to know how each CLI argument expects to be parsed. You can see all the different test cases we have, but the flag parsing is generic and doesn't know whether something expects arguments.
And to be clear, we don't "use" a space. We explode the arguments and pass them into exec()
(since that's how the syscall expects it).
This is the error I get - it's being quoted in the final command line
Error: google-github-actions/deploy-cloudrun failed with: failed to execute gcloud command
gcloud run jobs deploy test ... --command python "--args=-m,job.main"
: ERROR: (gcloud.run.jobs.deploy) unrecognized arguments: "--args=-m,job.main" (did you mean '--args'?)
Can you try using @main with the fully quoted flag (like I posted above)?
that worked!! thank you so much @sethvargo!
TL;DR
This GHA replaces
=
separated flags with space separate flags, which can cause parsing issues.Expected behavior
If I add in the flags
--command=python --args='-m,job.main'
, the output gcloud command should also be=
separated, which would result in a successful deploy.Observed behavior
The
=
gets replaced by a space by GHA, and the resultant flag sent to gcloud looks like--command python --args -m,job.main
. That leading dash for-m
causes a shell parsing error, which looks like:Action YAML
Log output
Additional information
This is only an issue if the first arg starts with a dash