diff --git a/readthedocs/projects/tasks/builds.py b/readthedocs/projects/tasks/builds.py index 156c3988b7a..1eb07042f4a 100644 --- a/readthedocs/projects/tasks/builds.py +++ b/readthedocs/projects/tasks/builds.py @@ -650,9 +650,18 @@ def get_valid_artifact_types(self): def on_success(self, retval, task_id, args, kwargs): valid_artifacts = self.get_valid_artifact_types() - # NOTE: we are updating the db version instance *only* when + # NOTE: we are updating the db version instance *only* if HTML build was successful # TODO: remove this condition and *always* update the DB Version instance if "html" in valid_artifacts: + if settings.READ_THE_DOCS_EXTENSIONS: + from readthedocsext.cdn.tasks import purge_tags # noqa + + if not self.data.version.built: + # When the version was previously NOT built and now this build was successful, + # we purge the Addons API cache for this project at this point. + # There is a new version that has to be shown in the flyout. + purge_tags.delay([self.data.project.slug, "rtd-addons"]) + try: self.data.api_client.version(self.data.version.pk).patch( {