Skip to content

fix: Action now parses "\" line seperator #182

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

squizzi
Copy link

@squizzi squizzi commented May 1, 2025

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

Signed-off-by: Kyle Squizzato <kyle@replicated.com>
@squizzi
Copy link
Author

squizzi commented May 1, 2025

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

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

Successfully merging this pull request may close these issues.

1 participant