From 40c2cb5b2e54c695cb531847b18ab2518128c793 Mon Sep 17 00:00:00 2001 From: shanecrowley Date: Wed, 11 Sep 2024 09:47:42 +0100 Subject: [PATCH] Set default filetype choice in CI. This prevents interactive prompting during test builds --- .github/workflows/test-starter-pack.yml | 4 ++++ init.sh | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-starter-pack.yml b/.github/workflows/test-starter-pack.yml index 6109d8da..754a1f7c 100644 --- a/.github/workflows/test-starter-pack.yml +++ b/.github/workflows/test-starter-pack.yml @@ -17,6 +17,8 @@ jobs: - name: Check out repo uses: actions/checkout@v4 - name: Run init and build + env: + default_filetype_choice: md # don't prompt for user choice run: sp-tests/run-init-and-build.sh - name: Add some files, build, and test run: sp-tests/add-files-and-build.sh @@ -46,6 +48,8 @@ jobs: - name: Check out repo uses: actions/checkout@v4 - name: Run init and build + env: + default_filetype_choice: md # don't prompt for user choice run: sp-tests/run-init-and-build.sh docs - name: Add some files, build, and test run: sp-tests/add-files-and-build.sh docs diff --git a/init.sh b/init.sh index 8cd00760..595f2b5e 100755 --- a/init.sh +++ b/init.sh @@ -33,7 +33,7 @@ while true; do done } -# If variable filetype choice is defined in CI then don't prompt user for choice +# If default variable for filetype choice is defined in CI then don't prompt user for choice if [ -z "${default_filetype_choice:-}" ]; then promptForFileChoice else @@ -111,14 +111,16 @@ echo "Copying contents to the installation directory..." cp -R "$temp_directory"/sp-files/* "$temp_directory"/sp-files/.??* "$install_directory" # Delete files with unpreferred filetype in the installation directory -if [ "$file_type" == 'md' ]; then - echo "Deleting rst files..." - rm "$install_directory"/index.rst - rm "$install_directory"/doc-cheat-sheet.rst -else - echo "Deleting md files..." - rm "$install_directory"/index.md - rm "$install_directory"/doc-cheat-sheet-myst.md +if [ ! -z "${default_filetype_choice:-}" ]; then + if [ "$file_type" == 'md' ]; then + echo "Deleting rst files..." + rm "$install_directory"/index.rst + rm "$install_directory"/doc-cheat-sheet.rst + else + echo "Deleting md files..." + rm "$install_directory"/index.md + rm "$install_directory"/doc-cheat-sheet-myst.md + fi fi # Ensure GitHub workflows and woke config are placed in the repo root