From a85f055e5ce8fe45b9c86e8ef07c6465750a6575 Mon Sep 17 00:00:00 2001 From: engeir Date: Wed, 10 Jan 2024 11:23:44 +0100 Subject: [PATCH 1/4] feat: add ability to set arguments that is passed to the latexmk command --- action.yml | 6 ++++++ entrypoint | 24 ++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index 83f276a..46c669a 100644 --- a/action.yml +++ b/action.yml @@ -13,12 +13,18 @@ inputs: required: false default: main.tex + arguments: + description: "Arguments passed to latexmk" + required: false + default: "" + runs: using: 'docker' image: 'Dockerfile' env: ACTION_FORMAT: ${{ inputs.format }} ACTION_FILENAME: ${{ inputs.filename }} + ACTION_ARGS: ${{ inputs.arguments }} branding: icon: 'book' diff --git a/entrypoint b/entrypoint index 3ad2224..ab27836 100644 --- a/entrypoint +++ b/entrypoint @@ -4,18 +4,22 @@ set -e command_string="latexmk" case "$ACTION_FORMAT" in - pdf) - command_string="$command_string -pdf" - ;; - *) - echo "Invalid input for action argument: format (must be pdf)" - exit 1 - ;; + pdf) + command_string="$command_string -pdf" + ;; + *) + echo "Invalid input for action argument: format (must be pdf)" + exit 1 + ;; esac +if [ ! "$ACTION_ARGS" = "" ]; then + for arg in "${ACTION_ARGS[@]}"; do + command_string="$command_string $arg" + done +fi -if [ -n "$ACTION_FILENAME" ] -then - command_string="$command_string $ACTION_FILENAME" +if [ "$ACTION_FILENAME" != "" ]; then + command_string="$command_string $ACTION_FILENAME" fi echo "Command: $command_string" From 594a72e394f140413db8e2a5a8a97d67ec9e3fee Mon Sep 17 00:00:00 2001 From: engeir Date: Wed, 10 Jan 2024 11:43:44 +0100 Subject: [PATCH 2/4] fix: loop splits on newline chars --- entrypoint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint b/entrypoint index ab27836..467113b 100644 --- a/entrypoint +++ b/entrypoint @@ -13,7 +13,7 @@ case "$ACTION_FORMAT" in ;; esac if [ ! "$ACTION_ARGS" = "" ]; then - for arg in "${ACTION_ARGS[@]}"; do + for arg in $ACTION_ARGS; do command_string="$command_string $arg" done fi From 1618445aff878ee75bf5e203cfbfa326b3524b8d Mon Sep 17 00:00:00 2001 From: engeir Date: Wed, 10 Jan 2024 12:04:28 +0100 Subject: [PATCH 3/4] style: use same style to minimise diff --- entrypoint | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/entrypoint b/entrypoint index 467113b..91989ec 100644 --- a/entrypoint +++ b/entrypoint @@ -4,13 +4,13 @@ set -e command_string="latexmk" case "$ACTION_FORMAT" in - pdf) - command_string="$command_string -pdf" - ;; - *) - echo "Invalid input for action argument: format (must be pdf)" - exit 1 - ;; + pdf) + command_string="$command_string -pdf" + ;; + *) + echo "Invalid input for action argument: format (must be pdf)" + exit 1 + ;; esac if [ ! "$ACTION_ARGS" = "" ]; then for arg in $ACTION_ARGS; do @@ -18,8 +18,9 @@ if [ ! "$ACTION_ARGS" = "" ]; then done fi -if [ "$ACTION_FILENAME" != "" ]; then - command_string="$command_string $ACTION_FILENAME" +if [ -n "$ACTION_FILENAME" ] +then + command_string="$command_string $ACTION_FILENAME" fi echo "Command: $command_string" From a086120b338e7c7a11e0f9dd85ad04c08d4a1370 Mon Sep 17 00:00:00 2001 From: engeir Date: Wed, 10 Jan 2024 12:13:33 +0100 Subject: [PATCH 4/4] fix(arguments): look for the `-pvc` argument and skip This will make latexmk run in continuous mode, and thus never terminate. --- entrypoint | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/entrypoint b/entrypoint index 91989ec..567aac7 100644 --- a/entrypoint +++ b/entrypoint @@ -14,7 +14,14 @@ case "$ACTION_FORMAT" in esac if [ ! "$ACTION_ARGS" = "" ]; then for arg in $ACTION_ARGS; do - command_string="$command_string $arg" + case "$arg" in + -pvc) + continue + ;; + *) + command_string="$command_string $arg" + ;; + esac done fi