Spaces:
Sleeping
Sleeping
Download scripts/setup_gh_secrets.sh from mipwr-admin/curium-intel: direct link, hf CLI and curl.
- Browser
- Download file 5.73 kB
-
https://huggingface.co/spaces/mipwr-admin/curium-intel/resolve/main/scripts/setup_gh_secrets.sh
- Command line
-
hf download hf://spaces/mipwr-admin/curium-intel/scripts/setup_gh_secrets.sh
-
curl -L -o setup_gh_secrets.sh https://huggingface.co/spaces/mipwr-admin/curium-intel/resolve/main/scripts/setup_gh_secrets.sh
5.73 kB
| # 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." | |