-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.envrc
More file actions
25 lines (22 loc) · 1.25 KB
/
Copy path.envrc
File metadata and controls
25 lines (22 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# --- Load secrets from Infisical ---
# Use safer error handling that doesn't conflict with VS Code's shell integration
set -eo pipefail # Exit on error and pipeline failures, but allow unset variables
# Try to get token from Infisical, fallback to existing environment variable
if [ -z "${GITHUB_PERSONAL_ACCESS_TOKEN:-}" ]; then
GITHUB_PERSONAL_ACCESS_TOKEN=$(infisical secrets get GITHUB_PERSONAL_ACCESS_TOKEN --path="/API-keys" --plain 2>/dev/null || true)
fi
# Fallback to .env file if still not set
if [ -z "${GITHUB_PERSONAL_ACCESS_TOKEN:-}" ] && [ -f ".env" ]; then
# Source .env file and extract GITHUB_PERSONAL_ACCESS_TOKEN
GITHUB_PERSONAL_ACCESS_TOKEN=$(grep "^GITHUB_PERSONAL_ACCESS_TOKEN=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' || true)
fi
# GitHub Personal Access Token handling
if [ -z "${GITHUB_PERSONAL_ACCESS_TOKEN:-}" ]; then
echo "⚠️ GITHUB_PERSONAL_ACCESS_TOKEN could not be retrieved from Infisical." >&2
echo "💡 To fix this, either:" >&2
echo " 1. Run 'infisical login' and 'infisical init' to set up Infisical" >&2
echo " 2. Set GITHUB_PERSONAL_ACCESS_TOKEN as an environment variable" >&2
echo " 3. Create a .env file with GITHUB_PERSONAL_ACCESS_TOKEN=your_token" >&2
else
export GITHUB_PERSONAL_ACCESS_TOKEN
fi