Open utterances-bot opened 3 months ago
Hello, do you how I can make Apollo Studio to fetch the script from Github? I don't want to manually add the script all the time and we also want to have some kind of versioning on this script to track the changes. Thanks!
@tbrehuescu that's a clever way to do it! This isn't an active project for me anymore, however I would assume that you could use GitHub releases to facilitate this. i.e. pull in the latest version of the script from GH, then use the eval
function to execute the response.
I generated a quick outline of the idea using Claude:
// Fetch the latest release information from GitHub
const getLatestRelease = async () => {
const response = await explorer.fetch('https://api.github.com/repos/YOUR_USERNAME/YOUR_REPO/releases/latest');
return response.json();
};
// Fetch the script content from GitHub
const fetchScriptContent = async (downloadUrl) => {
const response = await explorer.fetch(downloadUrl);
return response.text();
};
// Main preflight script
(async () => {
try {
// Get the current version from environment variables
const currentVersion = explorer.environment.get('script_version') || '0.0.0';
// Fetch the latest release info
const latestRelease = await getLatestRelease();
const latestVersion = latestRelease.tag_name;
// Compare versions
if (latestVersion !== currentVersion) {
console.log(`New version available: ${latestVersion}`);
// Fetch the new script content
const scriptContent = await fetchScriptContent(latestRelease.assets[0].browser_download_url);
// Update the environment with the new version and script
explorer.environment.set('script_version', latestVersion);
explorer.environment.set('oauth_script', scriptContent);
console.log('Script updated successfully');
} else {
console.log('Script is up to date');
}
// Execute the OAuth script
const oauthScript = explorer.environment.get('oauth_script');
if (oauthScript) {
eval(oauthScript);
} else {
console.error('OAuth script not found in environment');
}
} catch (error) {
console.error('Error updating script:', error);
}
})();
Hope this helps!
Automating Microsoft Active Directory OAuth in Apollo Sandbox with Scripts 🤖 - Max Monciardini
In this guide, I show you step-by-step how to automate Micrsoft Active Directory OAuth in your Apollo Sandbox environment.
https://www.mxmnci.com/blog/automating-oauth-in-apollo-sandbox