feat: enhance GitHub PAT retrieval and add MCP server configuration

This commit is contained in:
Peter Wood
2025-05-18 08:06:40 -04:00
parent 42c19c5533
commit fb657d1267
2 changed files with 29 additions and 1 deletions

View File

@@ -12,12 +12,22 @@ set -o pipefail
# Try to get PAT from environment first
pat="${GITHUB_PERSONAL_ACCESS_TOKEN:-}"
# If not in environment, try to get from GitHub CLI
# If not in environment, try to get from .env file
if [[ -z "${pat}" ]] || [[ "${#pat}" -lt 30 ]]; then
if [[ -f "${containerWorkspaceFolder}/.devcontainer/.env" ]]; then
source "${containerWorkspaceFolder}/.devcontainer/.env"
pat="${GITHUB_PERSONAL_ACCESS_TOKEN:-}"
fi
fi
# If still not set, try to get from GitHub CLI
if [[ -z "${pat}" ]] || [[ "${#pat}" -lt 30 ]]; then
if command -v gh &> /dev/null; then
if gh auth status &> /dev/null; then
pat=$(gh auth token)
if [[ -n "${pat}" ]] && [[ "${#pat}" -gt 30 ]]; then
# Export the token to environment
export GITHUB_PERSONAL_ACCESS_TOKEN="${pat}"
# Save the token to .env file if it's valid
ENV_FILE="/workspaces/finance/.devcontainer/.env"
echo "# GitHub Finance Devcontainer Configuration" > "${ENV_FILE}"