algolia / algoliasearch-netlify

Official Algolia Plugin for Netlify. Index your website to Algolia when deploying your project to Netlify with the Algolia Crawler
https://www.algolia.com/doc/tools/crawler/netlify-plugin/quick-start/
261 stars 10 forks source link

Option to prevent PRs from indexing #843

Open IstoraMandiri opened 2 years ago

IstoraMandiri commented 2 years ago

It seems that PR previews will trigger a full index if they have the same branch name as those defined in plugins.inputs.

Is there a way to skip the index when a repository, not just the branch, is specified?

sbellone commented 2 years ago

I don't understand, do you mean that the plugin triggers on a repository on which it's not installed?

IstoraMandiri commented 2 years ago

See this PR. It is https://github.com/ethereumclassic/ethereumclassic.github.io/pull/926

In the build, it is triggering an index, even though it is just a preview PR onto master, but the source repo is an outside contributor's "master" branch. I want to skip indexes for this scenario and only index when the main repo's master branch updates.

https://app.netlify.com/sites/ethereumclassic/deploys/6348c9bd9df5ae0008f78441#L212

sbellone commented 2 years ago

I see, thanks for the explanation. Indeed we'd have to see if there is a way to differentiate those preview PRs from the actual repository on Netlify side. Thanks for reporting!

IstoraMandiri commented 2 years ago

You are welcome.

Hopefully a fix is able to be identified as there are probably a few repos out there that generate previews from PRs, and using this plugin in this way could lead to search indexes being vandalized.

IstoraMandiri commented 2 years ago

@sbellone This can now be worked around using https://www.netlify.com/blog/scopes-and-contextual-values-for-environment-variables-ga/

EDIT: My mistake, this is only true for the gatsby-plugin-algolia indexing plugin, not the netlify plugin itself, sorry.

Still need this feature.