mirror of
https://github.com/acedanger/finance.git
synced 2025-12-06 07:00:13 -08:00
feat: enhance GitHub PAT retrieval and add MCP server configuration
This commit is contained in:
@@ -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}"
|
||||
|
||||
Reference in New Issue
Block a user