Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Plugins to GCP #1361

Open
5 of 8 tasks
beastoin opened this issue Nov 19, 2024 · 1 comment
Open
5 of 8 tasks

Migrate Plugins to GCP #1361

beastoin opened this issue Nov 19, 2024 · 1 comment
Assignees

Comments

@beastoin
Copy link
Collaborator

beastoin commented Nov 19, 2024

Migrate Plugins to GCP

deploy steps

  • deploy plugins to GCP
  • update its env, the re-deploy it:
  • migration Notion plugin
  • update Omi Mini-Apps in firestore which use the Plugins, point the url to new Plugin GCP Migrate Plugins to GCP #1361 (comment)
  • update the Zapier app, point to new Plugin hosting(GCP)
  • deprecate the modal > plugin after 1 month, must inform Zapier users.
@beastoin
Copy link
Collaborator Author

from urllib.parse import urlparse

from google.cloud import firestore

db = firestore.Client()

public_plugins = db.collection('plugins_data').stream()
plugins = [doc.to_dict() for doc in public_plugins]

def get_new_url(from_url: str):
    url = urlparse(from_url)
    if url.hostname == 'based-hardware--plugins-api.modal.run':
        new_url = 'https://plugins-hhibjajaja-uc.a.run.app' + url.path
        return new_url

    return None


# https://based-hardware--plugins-api.modal.run/setup-zapier
for plugin in plugins:
    need_update = False
    # auth steps
    for aidx, auth_step in enumerate(plugin.get('external_integration', {}).get('auth_steps', [])):
        new_url = get_new_url(auth_step['url'])
        if new_url:
            plugin['external_integration']['auth_steps'][aidx]['url'] = new_url
            need_update = True

    # setup_completed_url
    if 'setup_completed_url' in plugin.get('external_integration', {}):
        new_url = get_new_url(plugin['external_integration']['setup_completed_url'])
        if new_url:
            plugin['external_integration']['setup_completed_url'] = new_url
            need_update = True

    # webhook_url
    if 'webhook_url' in plugin.get('external_integration', {}):
        new_url = get_new_url(plugin['external_integration']['webhook_url'])
        if new_url:
            plugin['external_integration']['webhook_url'] = new_url
            need_update = True
    if need_update and plugin['id'] not in ['notion-crm', 'zapier']:
        print(f"update {plugin['id']}")
        print(plugin)
        app_ref = db.collection('plugins_data').document(plugin['id'])
        app_ref.update(plugin)
        print(f"done")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

No branches or pull requests

2 participants