Skip to content

chore: move Algolia search keys to environment variables - #2312

Open
isaque-bock-azion wants to merge 1 commit into
mainfrom
chore/algolia-env-keys
Open

chore: move Algolia search keys to environment variables#2312
isaque-bock-azion wants to merge 1 commit into
mainfrom
chore/algolia-env-keys

Conversation

@isaque-bock-azion

@isaque-bock-azion isaque-bock-azion commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

What

Moves the hardcoded Algolia DocSearch credentials out of source code into environment variables (PUBLIC_ALGOLIA_APP_ID and PUBLIC_ALGOLIA_SEARCH_KEY), per MM-15902 (Fase 0 — Docs Modernização).

  • BaseLayout.astro: AlgoliaDialog now reads the app id and search key from import.meta.env instead of inline literals
  • Removed the dead ALGOLIA_ID / ALGOLIA_APIKEY exports from src/consts.ts and all four env/consts.*.ts variants (nothing imported them)
  • Added .env.example documenting the required variables
  • dev.yml / stage.yml / prod.yml workflows export both variables from GitHub secrets in the build step

Action required before merge

The repository secrets PUBLIC_ALGOLIA_APP_ID and PUBLIC_ALGOLIA_SEARCH_KEY must be registered in GitHub (Settings → Secrets → Actions), otherwise the search dialog will render without credentials on the next deploy.

Validation

  • Full astro build passes locally (1494 pages) with the variables set via .env
  • Rendered HTML confirms the values are injected from the environment; grep confirms zero hardcoded keys left in src/, env/ and cicd/
  • Note: the search dialog does not hydrate in local dev mode on main either (pre-existing algoliasearch ESM interop issue in Vite dev, unrelated to this change)

Notes

The key being moved is Algolia's public search-only key, so this is hygiene/config cleanup rather than a secret leak remediation. The PUBLIC_ prefix is required by Astro to expose the values to the client-side dialog.

@isaque-bock-azion
isaque-bock-azion requested a review from a team August 10, 2026 18:01
…bles

Replace hardcoded Algolia app id and search-only api key with
PUBLIC_ALGOLIA_APP_ID and PUBLIC_ALGOLIA_SEARCH_KEY read via
import.meta.env, remove the unused ALGOLIA_ID/ALGOLIA_APIKEY exports
from consts, document the variables in .env.example, and export them
in the dev/stage/prod build workflows.

Refs: MM-15902
Comment thread .github/workflows/dev.yml
Comment on lines 32 to +35
export NODE_OPTIONS="--max-old-space-size=8120"
export PUBLIC_GITHUB_TOKEN="${{ secrets.GH_PACKAGES_SECRET }}"
export PUBLIC_ALGOLIA_APP_ID="${{ secrets.PUBLIC_ALGOLIA_APP_ID }}"
export PUBLIC_ALGOLIA_SEARCH_KEY="${{ secrets.PUBLIC_ALGOLIA_SEARCH_KEY }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those exports are not the best way to do this. My suggestion is to use env property of the github actions.

Comment on lines 40 to +43
export NODE_OPTIONS="--max-old-space-size=8120"
export PUBLIC_GITHUB_TOKEN="${{ secrets.GH_PACKAGES_SECRET }}"
export PUBLIC_ALGOLIA_APP_ID="${{ secrets.PUBLIC_ALGOLIA_APP_ID }}"
export PUBLIC_ALGOLIA_SEARCH_KEY="${{ secrets.PUBLIC_ALGOLIA_SEARCH_KEY }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same about env vs exports

Comment on lines 32 to +35
export NODE_OPTIONS="--max-old-space-size=8120"
export PUBLIC_GITHUB_TOKEN="${{ secrets.GH_PACKAGES_SECRET }}"
export PUBLIC_ALGOLIA_APP_ID="${{ secrets.PUBLIC_ALGOLIA_APP_ID }}"
export PUBLIC_ALGOLIA_SEARCH_KEY="${{ secrets.PUBLIC_ALGOLIA_SEARCH_KEY }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

samo about env vs exports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants