build-appimage icon indicating copy to clipboard operation
build-appimage copied to clipboard

GitHub Action is limited to 1 input argument

Open git-developer opened this issue 2 years ago • 0 comments

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.

git-developer avatar Sep 11 '23 17:09 git-developer