dagger-for-github
dagger-for-github copied to clipboard
fix: Action now parses "\" line seperator
When trying to use this action I tried to provide multi-line args to my call command, for example:
- name: Run Something
uses: dagger/dagger-for-github@v7
env:
API_TOKEN: ${{ steps.set-token.outputs.api_token }}
with:
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN}}
version: "latest"
verb: call
args: some-command \
--token=env:API_TOKEN \
--progress=plain
Which was resulting in a very perplexing error regarding required flags even when I could copy/paste the exact command from actions into my local CLI and run it fine:
Error: required flag(s) "token" not set
I realized that the with.args was wanting all of the args to sit on the same line and the \ separator was breaking the interpretation of those args.
So I updated the arg parsing in the bash in the action to support this use case. You can run this example to simulate the action input and the result:
#!/usr/bin/env bash
# Example: Simulate receiving multi-line args (as a single string)
ARGS_INPUT="--foo bar \
--baz qux \
--flag"
# Remove backslash-newline and any trailing spaces, do not include backslash in args
ARGS=$(echo "$ARGS_INPUT" | awk '{sub(/[ \t]*\\$/, ""); printf "%s", $0; if (!/[ \t]*\\$/) print ""}')
# Convert to array
read -r -a ARGS_ARRAY <<< "$ARGS"
# Show the resulting array
echo "Parsed arguments:"
for arg in "${ARGS_ARRAY[@]}"; do
echo "[$arg]"
done
echo "Result: dagger call some-call-command ${ARGS_ARRAY[@]}"
For example:
./bash-example.sh
Parsed arguments:
[--foo]
[bar]
[--baz]
[qux]
[--flag]
Result: dagger call some-call-command --foo bar --baz qux --flag
The folded style also doesn't work around this:
- name: Run Something
uses: dagger/dagger-for-github@v7
env:
API_TOKEN: ${{ steps.set-token.outputs.api_token }}
with:
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN}}
version: "latest"
verb: call
args: >
some-command
--token=env:API_TOKEN
--progress=plain