-
Notifications
You must be signed in to change notification settings - Fork 300
refactor: replace hardcoded /opt/gh-aw/ paths with GhAwHome constants #20864
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
Changes from 3 commits
c1be36b
2b437dc
9d3ac6b
6d05843
c2d6ac2
b0a4edd
e1eddb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,19 +14,28 @@ | |
|
|
||
| set -e | ||
|
|
||
| # Helper: create directories with sudo on macOS where /opt is root-owned | ||
| # Helper: create directories, falling back to sudo when /opt (or similar) is root-owned | ||
| create_dir() { | ||
| if [[ "$(uname -s)" == "Darwin" ]]; then | ||
| sudo mkdir -p "$1" | ||
| sudo chown -R "$(whoami)" "$1" | ||
| else | ||
| mkdir -p "$1" | ||
| if mkdir -p "$1" 2>/dev/null; then | ||
| return | ||
| fi | ||
| # Fall back to sudo if regular mkdir fails (e.g., /opt is root-owned on Linux and macOS) | ||
| sudo mkdir -p "$1" | ||
| sudo chown -R "$(whoami)" "$1" | ||
| } | ||
|
|
||
| # Get destination from input or use default | ||
| DESTINATION="${INPUT_DESTINATION:-/opt/gh-aw/actions}" | ||
|
|
||
| # Derive GH_AW_HOME from DESTINATION (strip /actions suffix) | ||
| # This allows setup.sh to be used with custom base directories | ||
| GH_AW_HOME="${DESTINATION%/actions}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice use of parameter expansion |
||
|
|
||
| # Export GH_AW_HOME to $GITHUB_ENV so all subsequent steps can use it | ||
| if [ -n "${GITHUB_ENV}" ]; then | ||
| echo "GH_AW_HOME=${GH_AW_HOME}" >> "${GITHUB_ENV}" | ||
| fi | ||
|
Comment on lines
28
to
+39
|
||
|
|
||
| # Get safe-output-custom-tokens flag from input (default: false) | ||
| SAFE_OUTPUT_CUSTOM_TOKENS_ENABLED="${INPUT_SAFE_OUTPUT_CUSTOM_TOKENS:-false}" | ||
|
|
||
|
|
@@ -118,7 +127,7 @@ fi | |
| echo "Successfully copied ${FILE_COUNT} files to ${DESTINATION}" | ||
|
|
||
| # Copy prompt markdown files to their expected directory | ||
| PROMPTS_DEST="/opt/gh-aw/prompts" | ||
| PROMPTS_DEST="${GH_AW_HOME}/prompts" | ||
| echo "Copying prompt markdown files to ${PROMPTS_DEST}" | ||
| create_dir "${PROMPTS_DEST}" | ||
|
|
||
|
|
@@ -140,7 +149,7 @@ else | |
| fi | ||
|
|
||
| # Copy mcp-scripts files to their expected directory | ||
| MCP_SCRIPTS_DEST="/opt/gh-aw/mcp-scripts" | ||
| MCP_SCRIPTS_DEST="${GH_AW_HOME}/mcp-scripts" | ||
| echo "Copying mcp-scripts files to ${MCP_SCRIPTS_DEST}" | ||
| create_dir "${MCP_SCRIPTS_DEST}" | ||
|
|
||
|
|
@@ -194,7 +203,7 @@ fi | |
| echo "Successfully copied ${MCP_SCRIPTS_COUNT} mcp-scripts files to ${MCP_SCRIPTS_DEST}" | ||
|
|
||
| # Copy safe-outputs files to their expected directory | ||
| SAFE_OUTPUTS_DEST="/opt/gh-aw/safeoutputs" | ||
| SAFE_OUTPUTS_DEST="${GH_AW_HOME}/safeoutputs" | ||
| echo "Copying safe-outputs files to ${SAFE_OUTPUTS_DEST}" | ||
| create_dir "${SAFE_OUTPUTS_DEST}" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -355,19 +355,19 @@ echo "Detected engine type: $ENGINE_TYPE" | |
| case "$ENGINE_TYPE" in | ||
| copilot) | ||
| echo "Using Copilot converter..." | ||
| bash /opt/gh-aw/actions/convert_gateway_config_copilot.sh | ||
| bash ${GH_AW_HOME:-/opt/gh-aw}/actions/convert_gateway_config_copilot.sh | ||
|
||
| ;; | ||
| codex) | ||
| echo "Using Codex converter..." | ||
| bash /opt/gh-aw/actions/convert_gateway_config_codex.sh | ||
| bash ${GH_AW_HOME:-/opt/gh-aw}/actions/convert_gateway_config_codex.sh | ||
| ;; | ||
| claude) | ||
| echo "Using Claude converter..." | ||
| bash /opt/gh-aw/actions/convert_gateway_config_claude.sh | ||
| bash ${GH_AW_HOME:-/opt/gh-aw}/actions/convert_gateway_config_claude.sh | ||
| ;; | ||
| gemini) | ||
| echo "Using Gemini converter..." | ||
| bash /opt/gh-aw/actions/convert_gateway_config_gemini.sh | ||
| bash ${GH_AW_HOME:-/opt/gh-aw}/actions/convert_gateway_config_gemini.sh | ||
|
||
| ;; | ||
| *) | ||
| echo "No agent-specific converter found for engine: $ENGINE_TYPE" | ||
|
|
@@ -384,13 +384,13 @@ echo "" | |
| # Check MCP server functionality | ||
| echo "Checking MCP server functionality..." | ||
| MCP_CHECK_START=$(date +%s%3N) | ||
| if [ -f /opt/gh-aw/actions/check_mcp_servers.sh ]; then | ||
| if [ -f ${GH_AW_HOME:-/opt/gh-aw}/actions/check_mcp_servers.sh ]; then | ||
| echo "Running MCP server checks..." | ||
| # Store check diagnostic logs in /tmp/gh-aw/mcp-logs/start-gateway.log for artifact upload | ||
| # Use tee to output to both stdout and the log file | ||
| # Enable pipefail so the exit code comes from check_mcp_servers.sh, not tee | ||
| set -o pipefail | ||
| if ! bash /opt/gh-aw/actions/check_mcp_servers.sh \ | ||
| if ! bash ${GH_AW_HOME:-/opt/gh-aw}/actions/check_mcp_servers.sh \ | ||
| /tmp/gh-aw/mcp-config/gateway-output.json \ | ||
| "http://localhost:${MCP_GATEWAY_PORT}" \ | ||
| "${MCP_GATEWAY_API_KEY}" 2>&1 | tee /tmp/gh-aw/mcp-logs/start-gateway.log; then | ||
|
|
@@ -402,7 +402,7 @@ if [ -f /opt/gh-aw/actions/check_mcp_servers.sh ]; then | |
| set +o pipefail | ||
| print_timing $MCP_CHECK_START "MCP server connectivity checks" | ||
| else | ||
| echo "WARNING: MCP server check script not found at /opt/gh-aw/actions/check_mcp_servers.sh" | ||
| echo "WARNING: MCP server check script not found at ${GH_AW_HOME:-/opt/gh-aw}/actions/check_mcp_servers.sh" | ||
| echo "Skipping MCP server functionality checks" | ||
| fi | ||
| echo "" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good improvement - using
mkdir -pfirst and only falling back tosudowhen needed. This is more portable across Linux environments where/optmay or may not require elevated permissions.