diff --git a/README.md b/README.md index 9aae345..dee4409 100644 --- a/README.md +++ b/README.md @@ -72,18 +72,25 @@ See also the [example repo](https://github.com/erikmd/docker-coq-github-action-d #### `opam_file` -**Required** the path of the `.opam` file, relative to the repo root. +*Optional* the path of the `.opam` file (or a directory), relative to the repo root. +Default `"."` (if the argument is omitted or an empty string). -*Note:* relying on the value of this `INPUT_OPAM_FILE` variable, the +*Note-1:* relying on the value of this `INPUT_OPAM_FILE` variable, the following two variables are exported when running the `custom_script`: ```bash -WORKDIR=$(dirname "$INPUT_OPAM_FILE") -PACKAGE=$(basename "$INPUT_OPAM_FILE" .opam) +if [ -z "$INPUT_OPAM_FILE" ] || [ -d "$INPUT_OPAM_FILE" ]; then + WORKDIR="" + PACKAGE=${INPUT_OPAM_FILE:-.} +else + WORKDIR=$(dirname "$INPUT_OPAM_FILE") + PACKAGE=$(basename "$INPUT_OPAM_FILE" .opam) +fi ``` -See also the -[`custom_script` default value](#custom_script). +*Note-2:* if this value is a directory (e.g., `.`), relying on the +[`custom_script` default value](#custom_script), the action will +install all the `*.opam` packages stored in this directory. #### `coq_version` diff --git a/action.yml b/action.yml index 97622fd..0858a2c 100644 --- a/action.yml +++ b/action.yml @@ -6,8 +6,8 @@ description: 'GitHub Action using Docker-Coq' author: 'Erik Martin-Dorel' inputs: opam_file: - description: 'The path of the .opam file, relative to the repo root.' - required: true + description: 'The path of the .opam file (or a directory), relative to the repo root.' + default: '.' coq_version: description: '"8.X", "latest", or "dev".' default: 'latest' diff --git a/entrypoint.sh b/entrypoint.sh index 660d86e..fdb4cb3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,8 +7,13 @@ timegroup_file="/app/timegroup.sh" # shellcheck source=./timegroup.sh . "$timegroup_file" -WORKDIR=$(dirname "$INPUT_OPAM_FILE") -PACKAGE=$(basename "$INPUT_OPAM_FILE" .opam) +if [ -z "$INPUT_OPAM_FILE" ] || [ -d "$INPUT_OPAM_FILE" ]; then + WORKDIR="" + PACKAGE=${INPUT_OPAM_FILE:-.} +else + WORKDIR=$(dirname "$INPUT_OPAM_FILE") + PACKAGE=$(basename "$INPUT_OPAM_FILE" .opam) +fi startGroup Print runner configuration @@ -52,7 +57,7 @@ Usage: $0 Options: -INPUT_OPAM_FILE: the path of the .opam file, relative to the repo root +INPUT_OPAM_FILE: the path of the .opam file (or a directory), relative to the repo root INPUT_COQ_VERSION: the version of Coq (without patch-level) INPUT_OCAML_VERSION: the version of OCaml (minimal, 4.07-flambda, 4.09-flambda) INPUT_CUSTOM_SCRIPT: the main script run in the container @@ -80,19 +85,6 @@ if test $# -gt 0; then echo "Warning: Arguments ignored: $*" fi -if test -z "$INPUT_OPAM_FILE"; then - echo "ERROR: No opam_file specified." - usage - exit 1 -fi - -case "$INPUT_OPAM_FILE" in - *.opam) - :;; - *) - echo "Warning: the opam_file argument should have the '.opam' suffix.";; -esac - if test -z "$INPUT_CUSTOM_IMAGE"; then if test -z "$INPUT_COQ_VERSION"; then echo "ERROR: No Coq version specified."