From 85e5eccab9b4e7b38097cfe7044f96bde7d500da Mon Sep 17 00:00:00 2001 From: Allison Thackston Date: Sat, 1 Oct 2022 05:49:34 +0000 Subject: [PATCH] Fix deploy script handling of custom config file --- .devcontainer/devcontainer.json | 3 ++- .vscode/launch.json | 6 ++++++ action.yml | 3 ++- docker/deploy.sh | 22 ++++++++++++++-------- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 72b028b2..00639357 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -38,7 +38,8 @@ "yzhang.markdown-all-in-one", "shakram02.bash-beautify", "eamodio.gitlens", - "streetsidesoftware.code-spell-checker" + "streetsidesoftware.code-spell-checker", + "rogalmic.bash-debug" ], // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "pip install --upgrade pip && pip install --user -r requirements.txt", diff --git a/.vscode/launch.json b/.vscode/launch.json index b68d2fc5..d043372f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,6 +12,12 @@ "console": "integratedTerminal", "justMyCode": true }, + { + "name": "Bash: Current File", + "type": "bashdb", + "request": "launch", + "program": "${file}", + }, { "name": "Test: Build Mkdocs", "type": "python", diff --git a/action.yml b/action.yml index eb3695e4..dce7590e 100644 --- a/action.yml +++ b/action.yml @@ -28,7 +28,7 @@ # # (optional) Specify a different theme [mkdocs|readthedocs|material] # theme: material # # (optional) Load a configuration file from a string -# config: "{additional_css: value}" +# config: "mkdocs.yml" # # (optional) Version or alias. Specify multiple aliases with space # # example: version: v0.1.0 latest # version: latest @@ -74,6 +74,7 @@ inputs: config: description: "Configuration file" required: false + default: mkdocs.yml version: description: "Version to publish" required: false diff --git a/docker/deploy.sh b/docker/deploy.sh index 2c36d1b4..fe3126ae 100755 --- a/docker/deploy.sh +++ b/docker/deploy.sh @@ -1,35 +1,41 @@ #!/bin/bash - set -e + UNSET='\033[0m' RED='\033[00;31m' GREEN='\033[00;32m' YELLOW='\033[00;33m' CYAN='\033[00;36m' - git config --global --add safe.directory /github/workspace +INPUT_CONFIG=${INPUT_CONFIG:-'mkdocs.yml'} +INPUt_PUBLISH_BRANCH=${INPUT_PUBLISH_BRANCH:-'gh-pages'} +INPUT_PUSH=${INPUT_PUSH:-'true'} + echo -e "${CYAN}Building docs${UNSET}" -mkdocs_simple_gen --config-file ${INPUT_CONFIG:-'mkdocs.yml'} -mkdocs build +mkdocs_simple_gen --config-file ${INPUT_CONFIG} if [[ "${INPUT_PUSH}" == "1" || "${INPUT_PUSH,,}" == "true" ]]; then - git config --global user.name "${GITHUB_ACTOR}" - git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + if [ "${GITHUB_ACTOR}" ]; then + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + fi git fetch origin ${INPUT_PUBLISH_BRANCH} --depth=1 || echo -e "${YELLOW}skipping fetch${UNSET}" if [ "${INPUT_VERSION}" ]; then echo -e "${CYAN}Deploying ${INPUT_VERSION} to ${INPUT_PUBLISH_BRANCH}${UNSET}" - mike deploy -p -u -b ${INPUT_PUBLISH_BRANCH} ${INPUT_VERSION} + mike deploy --config-file ${INPUT_CONFIG} -p -u -b ${INPUT_PUBLISH_BRANCH} ${INPUT_VERSION} else echo -e "${CYAN}Deploying docs to ${INPUT_PUBLISH_BRANCH}${UNSET}" - mkdocs gh-deploy -b ${INPUT_PUBLISH_BRANCH} + mkdocs gh-deploy --config-file ${INPUT_CONFIG} -b ${INPUT_PUBLISH_BRANCH} fi if [ "${INPUT_DEFAULT_VERSION}" ]; then echo -e "${CYAN}Setting default version to ${INPUT_DEFAULT_VERSION}${UNSET}" mike set-default -p -b ${INPUT_PUBLISH_BRANCH} ${INPUT_DEFAULT_VERSION} fi +else + mkdocs build fi