Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple installation of IE and scenarios. #189

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/scenario-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ jobs:
- uses: actions/checkout@v2
- name: Check ie installation
run: |
set -e
cat scripts/install_from_release.sh | /bin/bash
if ! command -v ie; then
echo "ie not found"
exit 1
fi

bash scripts/install_docs_from_release.sh en-us v1.0.1
if [ ! -d "${HOME}/scenarios" ]
then
echo "scenarios not found"
Expand Down
67 changes: 67 additions & 0 deletions scripts/install_docs_from_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Script to install documentation from our upstream repository.

set -e

# TODO: make parameters mandatory
LANG="$1"
RELEASE="$2"

# If no release is specified, download the latest release
if [ "$RELEASE" == "" ]; then
RELEASE="latest"
fi

# Set a default scenarios file
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/$RELEASE/scenarios.zip"

# If the LANG parameter was set, download appropriate script
if [ "$LANG" != "" ]; then
# Map the language parameter to the corresponding scenarios file
# If no parameter, download the scenarios from IE
MAIN_LANG_PREFIX="$(echo "$LANG" | head -c2 | tr '[:upper:]' '[:lower:]')"
LANG_ARRAY=("de" "es" "fr" "it" "nl" "pt" "zh" "cs" "hu" "id" "ja" "ko" "pl" "pt" "ru" "sv" "tr")

if [[ "${LANG_ARRAY[*]}" =~ "$MAIN_LANG_PREFIX" ]]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-$MAIN_LANG_PREFIX-scenarios.zip"
if [ "$MAIN_LANG_PREFIX" = "pt" ]; then
if [ "$LANG" = "pt-pt" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
elif [ "$LANG" = "pt-br" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-br-scenarios.zip"
else
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
fi
fi
if [ "$MAIN_LANG_PREFIX" = "zh" ]; then
if [ "$LANG" = "zh-cn" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
elif [ "$LANG" = "zh-tw" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-tw-scenarios.zip"
else
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
fi
fi
if [ "$MAIN_LANG_PREFIX" = "cs" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-cz-scenarios.zip"
fi
if [ "$MAIN_LANG_PREFIX" = "ja" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-jp-scenarios.zip"
fi
if [ "$MAIN_LANG_PREFIX" = "ko" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-kr-scenarios.zip"
fi
if [ "$MAIN_LANG_PREFIX" = "sv" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-se-scenarios.zip"
fi
fi
fi

# Download the scenarios.
echo "Installing scenarios from the $RELEASE release..."
wget -q -O scenarios.zip "$SCENARIOS" >/dev/null

# Unzip the scenarios, overwrite if they already exist.
unzip -o scenarios.zip -d ~ >/dev/null
rm scenarios.zip >/dev/null

echo "Done."
68 changes: 8 additions & 60 deletions scripts/install_from_release.sh
Original file line number Diff line number Diff line change
@@ -1,77 +1,25 @@
# Script to install scenarios file. Pass in language code parameter for a particular language, such as it-it for Italian.
set -e

# TODO: make parameters mandatory
LANG="$1"
RELEASE="$2"
RELEASE="$1"

# If no release is specified, download the latest release
if [ "$RELEASE" == "" ]; then
RELEASE="latest"
fi

# Set a default scenarios file
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/scenarios.zip"

# If the LANG parameter was set, download appropriate script
if [ -n "$LANG" ]; then
# Map the language parameter to the corresponding scenarios file
# If no parameter, download the scenarios from IE
MAIN_LANG_PREFIX="$(echo "$LANG" | head -c2 | tr '[:upper:]' '[:lower:]')"
LANG_ARRAY=("de" "es" "fr" "it" "nl" "pt" "zh" "cs" "hu" "id" "ja" "ko" "pl" "pt" "ru" "sv" "tr")

if [[ "${LANG_ARRAY[*]}" =~ "$MAIN_LANG_PREFIX" ]]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-$MAIN_LANG_PREFIX-scenarios.zip"
if [ "$MAIN_LANG_PREFIX" = "pt" ]; then
if [ "$LANG" = "pt-pt" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
elif [ "$LANG" = "pt-br" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-br-scenarios.zip"
else
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
fi
fi
if [ "$MAIN_LANG_PREFIX" = "zh" ]; then
if [ "$LANG" = "zh-cn" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
elif [ "$LANG" = "zh-tw" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-tw-scenarios.zip"
else
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
fi
fi
if [ "$MAIN_LANG_PREFIX" = "cs" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-cz-scenarios.zip"
fi
if [ "$MAIN_LANG_PREFIX" = "ja" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-jp-scenarios.zip"
fi
if [ "$MAIN_LANG_PREFIX" = "ko" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-kr-scenarios.zip"
fi
if [ "$MAIN_LANG_PREFIX" = "sv" ]; then
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-se-scenarios.zip"
fi
fi
RELEASE="latest"
fi

# Download the binary
echo "Installing IE & scenarios from the $RELEASE release..."
wget -q -O ie https://github.com/Azure/InnovationEngine/releases/download/$RELEASE/ie > /dev/null
wget -q -O scenarios.zip "$SCENARIOS" > /dev/null
echo "Installing IE from the $RELEASE release..."
wget -q -O ie https://github.com/Azure/InnovationEngine/releases/download/"$RELEASE"/ie >/dev/null

# Setup permissions & move to the local bin
chmod +x ie > /dev/null
mkdir -p ~/.local/bin > /dev/null
mv ie ~/.local/bin > /dev/null

# Unzip the scenarios, overwrite if they already exist.
unzip -o scenarios.zip -d ~ > /dev/null
rm scenarios.zip > /dev/null
chmod +x ie >/dev/null
mkdir -p ~/.local/bin >/dev/null
mv ie ~/.local/bin >/dev/null

# Export the path to IE if it's not already available
if [[ !"$PATH" =~ "~/.local/bin" || !"$PATH" =~ "$HOME/.local/bin" ]]; then
export PATH="$PATH:~/.local/bin"
export PATH="$PATH:~/.local/bin"
fi

echo "Done."
Loading