From 0ed4f972f2a44f8ca02b6250c411c191746edfa3 Mon Sep 17 00:00:00 2001 From: Manoel Campos Date: Wed, 14 Jul 2021 15:34:45 -0300 Subject: [PATCH] Close #21 --- .github/workflows/asciidoctor-ghpages.yml | 1 + action.yml | 5 +++++ entrypoint.sh | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/asciidoctor-ghpages.yml b/.github/workflows/asciidoctor-ghpages.yml index 1a2eb5c..2b9ab2c 100644 --- a/.github/workflows/asciidoctor-ghpages.yml +++ b/.github/workflows/asciidoctor-ghpages.yml @@ -29,4 +29,5 @@ jobs: # adoc_file_ext: .ascii # default is .adoc # source_dir: docs/ # default is . # slides_build: true + # pre_build: # post_build: diff --git a/action.yml b/action.yml index 47be5cb..5aa3d0a 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,10 @@ inputs: description: 'If slides are being generated using AsciiDoc Reveal.js, you may not want to build the regular html files using the asciidoctor command, but just using the asciidoctor-revealjs command. In order to generate only the slides.html instead of the regular html files, set this config to true.' default: 'false' required: false + pre_build: + description: 'Any arbitrary shell command to be executed before the asciidoc build is started. Optional.' + default: 'echo "No pre build command provided."' + required: false post_build: description: 'Any arbitrary shell command to be executed after the asciidoc build is complete and before committing changes on gh-pages branch. Optional.' default: 'echo "No post build command provided."' @@ -54,4 +58,5 @@ runs: - ${{ inputs.slides_skip_asciidoctor_build }} - ${{ inputs.pdf_build }} - ${{ inputs.ebook_main_adoc_file }} + - ${{ inputs.pre_build }} - ${{ inputs.post_build }} diff --git a/entrypoint.sh b/entrypoint.sh index 41d828a..efb7a04 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,8 +3,6 @@ # Exit if a command fails set -e -sh -c "echo 'Input Parameters:' $*" - OWNER="$(echo $GITHUB_REPOSITORY| cut -d'/' -f 1)" if [[ "$INPUT_ADOC_FILE_EXT" != .* ]]; then @@ -43,6 +41,11 @@ else git checkout "$COMMIT_HASH" -B gh-pages fi +# Executes any arbitrary shell command (such as packages installation and environment setup) +# before starting build. +# If no command is provided, the default value is just an echo command. +eval "$INPUT_PRE_BUILD" + if [[ $INPUT_SLIDES_SKIP_ASCIIDOCTOR_BUILD == false ]]; then echo "Converting AsciiDoc files to HTML" find . -name "*$INPUT_ADOC_FILE_EXT" | xargs asciidoctor -b html $INPUT_ASCIIDOCTOR_PARAMS