Spaces:
Sleeping
Sleeping
File size: 5,727 Bytes
e09465e 48cb4ed 27f7662 48cb4ed e09465e 48cb4ed e09465e | 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | #!/usr/bin/env bash
# Interactive helper: populate the GitHub Actions secrets needed by the
# weekly hunt + digest workflow. Run this LOCALLY in your own Terminal
# (not via an automation tool β sensitive prompts use `read -s` which
# needs a real TTY).
#
# Values are piped to `gh secret set` via stdin β never appear on argv,
# never written to disk, never echoed to terminal/chat.
#
# Usage: bash scripts/setup_gh_secrets.sh
# Re-run any time to overwrite or add specific secrets.
set -euo pipefail
REPO="pierslyon/curium-lead-intelligence"
ENV_FILE="$(dirname "$(dirname "$(realpath "$0")")")/.env"
# -----------------------------------------------------------------------------
# Helpers
# -----------------------------------------------------------------------------
# Read a value from .env. Returns empty if missing or value is blank.
env_value() {
local key="$1"
if [ ! -f "$ENV_FILE" ]; then return; fi
while IFS='=' read -r k v; do
if [ "$k" = "$key" ]; then
v="${v#\"}"; v="${v%\"}"; v="${v#\'}"; v="${v%\'}"
printf '%s' "$v"
return
fi
done < "$ENV_FILE"
}
# Set a GH repo secret from stdin. Skips if value is empty.
set_secret() {
local name="$1" value="$2"
if [ -z "$value" ]; then
echo " β οΈ $name β skipped (empty value)"
return
fi
printf '%s' "$value" | gh secret set "$name" --repo "$REPO" >/dev/null
echo " β $name"
}
# Prompt for a value. Modes:
# silent : hidden input (sensitive)
# visible: visible input
# If a non-empty default is provided AND the user just hits enter, the
# default is used. For silent prompts, default is shown only as "(*** existing
# value retained ***)" so the user knows there's something to fall back to.
prompt() {
local label="$1" mode="$2" default="${3:-}"
local value=""
if [ "$mode" = "silent" ]; then
if [ -n "$default" ]; then
read -s -p " ${label} [enter = keep existing]: " value
else
read -s -p " ${label}: " value
fi
echo
else
if [ -n "$default" ]; then
read -p " ${label} [${default}]: " value
else
read -p " ${label}: " value
fi
fi
if [ -z "$value" ] && [ -n "$default" ]; then
value="$default"
fi
printf '%s' "$value"
}
# Prompt + set in one go.
prompt_and_set() {
local secret_name="$1" label="$2" mode="$3" default="${4:-}"
local value
value="$(prompt "$label" "$mode" "$default")"
set_secret "$secret_name" "$value"
}
# -----------------------------------------------------------------------------
echo "β Target repo: ${REPO}"
echo "β Local .env: ${ENV_FILE}"
echo
echo "(input is hidden for sensitive items β re-run anytime to overwrite)"
echo
# -----------------------------------------------------------------------------
echo "Anthropic + integration keys"
prompt_and_set "ANTHROPIC_API_KEY" "ANTHROPIC_API_KEY" silent "$(env_value ANTHROPIC_API_KEY)"
prompt_and_set "COMPANIES_HOUSE_API_KEY" "COMPANIES_HOUSE_API_KEY" silent "$(env_value COMPANIES_HOUSE_API_KEY)"
prompt_and_set "NEWSAPI_KEY" "NEWSAPI_KEY" silent "$(env_value NEWSAPI_KEY)"
prompt_and_set "ADZUNA_APP_ID" "ADZUNA_APP_ID" silent ""
prompt_and_set "ADZUNA_APP_KEY" "ADZUNA_APP_KEY" silent ""
echo
echo "Hugging Face Dataset persistence (same values as the HF Space)"
prompt_and_set "HF_TOKEN" "HF_TOKEN (write scope, hf_...)" silent ""
prompt_and_set "HF_STATE_REPO" "HF_STATE_REPO" visible "mipwr-admin/curium-intel-state"
echo
echo "Microsoft Graph (M365 service-account path β recommended)"
echo " Set up via Azure AD App Registration with Mail.Send application permission."
prompt_and_set "MS_GRAPH_TENANT_ID" "MS_GRAPH_TENANT_ID (tenant GUID)" visible ""
prompt_and_set "MS_GRAPH_CLIENT_ID" "MS_GRAPH_CLIENT_ID (App Registration client ID)" visible ""
prompt_and_set "MS_GRAPH_CLIENT_SECRET" "MS_GRAPH_CLIENT_SECRET (client secret value)" silent ""
prompt_and_set "MS_GRAPH_FROM_EMAIL" "MS_GRAPH_FROM_EMAIL (mailbox to send AS)" visible "intelligence@curiumsolutions.com"
prompt_and_set "MS_GRAPH_FROM_NAME" "MS_GRAPH_FROM_NAME" visible "Curium Lead Intelligence"
prompt_and_set "MS_GRAPH_REPLY_TO" "MS_GRAPH_REPLY_TO (optional β leave blank to default to your ADMIN_EMAIL)" visible ""
echo
echo "SMTP fallback (only used if Graph vars above are blank β skip if you set Graph)"
prompt_and_set "SMTP_HOST" "SMTP_HOST" visible ""
prompt_and_set "SMTP_PORT" "SMTP_PORT" visible "587"
prompt_and_set "SMTP_FROM_NAME" "SMTP_FROM_NAME" visible "Curium Lead Intelligence"
prompt_and_set "SMTP_FROM_EMAIL" "SMTP_FROM_EMAIL" visible ""
prompt_and_set "SMTP_USERNAME" "SMTP_USERNAME" silent "$(env_value SMTP_USERNAME)"
prompt_and_set "SMTP_PASSWORD" "SMTP_PASSWORD" silent "$(env_value SMTP_PASSWORD)"
echo
echo "Recipients (visible β these aren't credentials)"
prompt_and_set "HENRIETTE_EMAIL" "HENRIETTE_EMAIL" visible ""
prompt_and_set "ADMIN_EMAIL" "ADMIN_EMAIL (gets dry-run digests)" visible ""
echo
# -----------------------------------------------------------------------------
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "Done. Secrets currently on the repo:"
echo
gh secret list --repo "$REPO"
echo
echo "Next: open https://github.com/${REPO}/actions"
echo " β Weekly hunt + digest emails β Run workflow"
echo " β keep dry_run=true β run."
echo " β digest arrives at the ADMIN_EMAIL you set above."
|