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

GitHub Action is limited to 1 input argument #7

Open
git-developer opened this issue Sep 11, 2023 · 0 comments · May be fixed by #9
Open

GitHub Action is limited to 1 input argument #7

git-developer opened this issue Sep 11, 2023 · 0 comments · May be fixed by #9

Comments

@git-developer
Copy link

Problem

The GitHub Action is limited to a single input argument.

Cause

Currently, action.yml looks like this:

  args:
    - appimage-builder
    - '--recipe=${{ inputs.recipe }}' 
    - '${{ inputs.args }}'

inputs.args is not a list, but a single string. Thus it is not possible to use more than one argument. Example:

  uses: AppImageCrafters/[email protected]
  with:
    recipe: dist/AppImageBuilder.yml
    args: --skip-tests --appdir "Custom AppDir"

This will run the appimage-builder container with 3 arguments:

  • appimage-builder
  • --recipe=dist/AppImageBuilder.yml
  • --skip-tests --appdir "Custom AppDir"

The container run fails because it the input args are merged into one big string:

/usr/bin/docker run [...] appimagecrafters/appimage-builder:1.1.0  "appimage-builder" "--recipe=dist/AppImageBuilder.yml" "--appdir \"CustomAppDir\" --skip-tests"
usage: appimage-builder [-h] [-v] [--recipe RECIPE] [--build-dir BUILD_DIR]
                        [--appdir APPDIR] [--log LOGLEVEL] [--skip-script]
                        [--skip-build] [--skip-tests] [--skip-appimage]
                        [--generate]
appimage-builder: error: unrecognized arguments: "--skip-tests --appdir \"Custom AppDir\""

Possible Solutions

The image must be called using a JSON list instead (see docs):

runs:
  using: 'docker'
  image: docker://appimagecrafters/appimage-builder:1.1.0
  args: [ "appimage-builder", "--recipe=dist/AppImageBuilder.yml", "--skip-tests", "--appdir", "Custom AppDir" ]

To do that, input.args must be split. There are several possibilities todo that.

Newline-separated list

docker/build-push-action uses newlines as separator. It would look like

- build-args: |
  --skip-tests
  --appdir
  "Custom AppDir"

I don't know how to convert this to a JSON list, they use a library.

JSON list

An alternative is to use the string representation of a JSON list. This would look like:

- build-args: '[ "--skip-tests", "--appdir", "Custom AppDir" ]'

This string can be converted to a JSON list using the fromJSON() function.

Once the arguments are in JSON list representation, the two args appimage-builder and --recipe=... have to be added to the head of the list.

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 a pull request may close this issue.

1 participant