Repository navigation
Open
Description
What is the issue?
Given the following config:
https://github.com/lukemarsden/test-dagger-actions/blob/c0e90ddf436947e4c6639fd95e2c491095f87ff5/.github/workflows/docker-publish.yml
In particular,
- name: Dagger Build & Push
uses: dagger/dagger-for-github@v5
with:
version: "0.11.0"
verb: call
args: |
build-and-push \
--registry=$DOCKER_REGISTRY \
--image-name=$DOCKER_IMAGE_NAME \
--username=$DOCKER_USERNAME \
--password=env:DOCKER_PASSWORD
env:
DOCKER_REGISTRY: ${{ env.REGISTRY }}
DOCKER_IMAGE_NAME: ${{ env.IMAGE_NAME }}
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
When using the multi-line string args: |, I suppose the string ends up including the trailing newline at the end, which results in the following error: https://github.com/lukemarsden/test-dagger-actions/actions/runs/8630455004/job/23656748756
In particular:
Run cd . && { \
cd . && { \
DAGGER_CLOUD_TOKEN= \
dagger \
--progress plain \
call \
${INPUT_MODULE:+-m $INPUT_MODULE} \
build-and-push \
--registry=$DOCKER_REGISTRY \
--image-name=$DOCKER_IMAGE_NAME \
--username=$DOCKER_USERNAME \
--***
; }
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
REGISTRY: ghcr.io
IMAGE_NAME: lukemarsden/test-dagger-actions
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: lukemarsden/test-dagger-actions
DOCKER_USERNAME: lukemarsden
DOCKER_PASSWORD: ***
INPUT_MODULE:
/home/runner/work/_temp/18dc8cb9-bd6c-4e31-adb8-b2[96](https://github.com/lukemarsden/test-dagger-actions/actions/runs/8630455004/job/23656748756#step:3:98)01d09f1c.sh: line 12: syntax error near unexpected token `;'
Error: Process completed with exit code 2.
Switching to single line style, like:
args: build-and-push --registry=$DOCKER_REGISTRY --image-name=$DOCKER_IMAGE_NAME --username=$DOCKER_USERNAME --password=env:DOCKER_PASSWORD --build-context .
fixes the issue, but of course is less readable
Dagger version
dagger v0.11.0 (registry.dagger.io/engine) darwin/arm64
Steps to reproduce
Run the above config
Log output
See above
Reacted by Scott Ames, Harley Lang, Liam Jones and Anders K. Pettersen
Metadata
Metadata
Assignees
Labels
No labels
Activity
esafak commentedon May 3, 2024
Try adding a
\to the last line too.harleylang commentedon May 3, 2024
Unfortunately that does not work because part of the issue with using a multiline value for the
argsinput is that either:The trailing semicolon gets kicked to the next line which internally results in the reported
syntax error near unexpected token ';', see:dagger-for-github/action.yml
Line 69 in 51ce834
Or if all lines have a trailing backslash and are clipped then the backslashes persist and will confuse Dagger with the observed error of
Error: unknown command " --dir=." for "dagger call"For example, this:
Is clipped to an
argsvalue of:--env=*** \ --dir=. \ pipelineand those inline backslashes are not ignored.A workaround is to use a block chomping indicator and no backslashes. For example the following will work:
I think an ideal expected behaviour for the
argsinput should be to either: (1) handle the various ways yaml can provide a multiline value or (2) parse and throw a more verbose error that prompts users to use the above syntax. Solution 1 is probably out of scope for an action like this. But given that many folks will want to chop up their Dagger call into something readable and maintainable perhaps solution 2 would work simply by parsing the providedargswith a regex and shouting for the user to review either this comment or documentation that recommends this strategy for multilineargsinput.