mirror of
https://github.com/acedanger/finance.git
synced 2025-12-05 14:40: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}"
|
||||
|
||||
18
.vscode/settings.json
vendored
18
.vscode/settings.json
vendored
@@ -18,5 +18,23 @@
|
||||
"port": "443",
|
||||
"baseUrl": "https://finance-app-production.example.com/api"
|
||||
}
|
||||
},
|
||||
"mcp": {
|
||||
"servers": {
|
||||
"github": {
|
||||
"command": "docker",
|
||||
"args": [
|
||||
"run",
|
||||
"-i",
|
||||
"--rm",
|
||||
"-e",
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN=${env:GITHUB_PERSONAL_ACCESS_TOKEN}",
|
||||
"ghcr.io/github/github-mcp-server"
|
||||
],
|
||||
"env": {
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${env:GITHUB_PERSONAL_ACCESS_TOKEN}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user