microsoft/hve-core

Public

mirrored from https://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
docs/transparency-note

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/skills/installer/hve-core-installer/scripts/detect-environment.sh

38lines · modecode

1#!/usr/bin/env bash
2# Copyright (c) Microsoft Corporation.
3# SPDX-License-Identifier: MIT
4# Detects the current development environment for HVE-Core installation.
5# Outputs key-value pairs: ENV_TYPE, IS_CODESPACES, IS_DEVCONTAINER,
6# HAS_DEVCONTAINER_JSON, HAS_WORKSPACE_FILE, IS_HVE_CORE_REPO.
7set -euo pipefail
8
9# Detect environment type
10env_type="local"
11is_codespaces=false
12is_devcontainer=false
13
14if [ "${CODESPACES:-}" = "true" ]; then
15 env_type="codespaces"
16 is_codespaces=true
17 is_devcontainer=true
18elif [ -f "/.dockerenv" ] || [ "${REMOTE_CONTAINERS:-}" = "true" ]; then
19 env_type="devcontainer"
20 is_devcontainer=true
21fi
22
23has_devcontainer_json=false
24[ -f ".devcontainer/devcontainer.json" ] && has_devcontainer_json=true
25
26has_workspace_file=false
27[ -n "$(find . -maxdepth 1 -name '*.code-workspace' -print -quit 2>/dev/null)" ] && has_workspace_file=true
28
29is_hve_core_repo=false
30repo_root=$(git rev-parse --show-toplevel 2>/dev/null || true)
31[ -n "$repo_root" ] && [ "$(basename "$repo_root")" = "hve-core" ] && is_hve_core_repo=true
32
33echo "ENV_TYPE=$env_type"
34echo "IS_CODESPACES=$is_codespaces"
35echo "IS_DEVCONTAINER=$is_devcontainer"
36echo "HAS_DEVCONTAINER_JSON=$has_devcontainer_json"
37echo "HAS_WORKSPACE_FILE=$has_workspace_file"
38echo "IS_HVE_CORE_REPO=$is_hve_core_repo"
39