#!/bin/bash set -e function get_environment { dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" LOCAL_BUILD_DIR="$(cd "$dir/../.." && pwd)" export GITHUB_WORKSPACE="$LOCAL_BUILD_DIR" # shellcheck source=/dev/null [[ -f "${GITHUB_WORKSPACE}/test/local_test_env.sh" ]] && \ source "${GITHUB_WORKSPACE}/test/local_test_env.sh" # Get the environment variables from the .github/workflows/test.yml file with sed declare -a ci_test_yml ci_test_yml[0]="$(sed -n 's/.* NGINX_CONTAINER_NAME: //p' "$LOCAL_BUILD_DIR/.github/workflows/test.yml")" ci_test_yml[1]="$(sed -n 's/.* DOCKER_GEN_CONTAINER_NAME: //p' "$LOCAL_BUILD_DIR/.github/workflows/test.yml")" ci_test_yml[2]="$(sed -n 's/.* TEST_DOMAINS: //p' "$LOCAL_BUILD_DIR/.github/workflows/test.yml")" # If environment variable where sourced or manually set use them, else use those from # .github/workflows/test.yml export NGINX_CONTAINER_NAME="${NGINX_CONTAINER_NAME:-${ci_test_yml[0]}}" export DOCKER_GEN_CONTAINER_NAME="${DOCKER_GEN_CONTAINER_NAME:-${ci_test_yml[1]}}" export TEST_DOMAINS="${TEST_DOMAINS:-${ci_test_yml[2]}}" # Build the array containing domains to add to /etc/hosts IFS=',' read -r -a domains <<< "$TEST_DOMAINS" if [[ -z $SETUP ]]; then while true; do echo "Which nginx-proxy setup do you want to test or remove ?" echo "" echo " 1) Two containers setup (nginx-proxy + le-companion)" echo " 2) Three containers setup (nginx + docker-gen + le-companion)" read -re -p "Select an option [1-2]: " option case $option in 1) setup="2containers" break ;; 2) setup="3containers" break ;; *) : ;; esac done fi export SETUP="${SETUP:-$setup}" if [[ -z $ACME_CA ]]; then while true; do echo "Which ACME CA do you want to use or remove ?" echo "" echo " 1) Boulder https://github.com/letsencrypt/boulder" echo " 2) Pebble https://github.com/letsencrypt/pebble" read -re -p "Select an option [1-2]: " option case $option in 1) acme_ca="boulder" break ;; 2) acme_ca="pebble" break ;; *) : ;; esac done fi export ACME_CA="${ACME_CA:-$acme_ca}" } case $1 in --setup) get_environment # Prepare the env file that run.sh will source cat > "${GITHUB_WORKSPACE}/test/local_test_env.sh" <