Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Update api spec script

Jakub Novak365ef328a509
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..ee84c9828
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+update-api-spec:
+ @echo "Updating API spec"
+ @./scripts/update-api-spec.sh
+ @echo "Done"
diff --git a/scripts/update-api-spec.sh b/scripts/update-api-spec.sh
new file mode 100755
index 000000000..100a87ad5
--- /dev/null
+++ b/scripts/update-api-spec.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+set -eu
+
+# This script is used to update the spec/openapi.yml file from the api repo
+
+# Check if the remote is set
+if [ -z "$(git remote get-url api)" ]; then
+ git remote add api [email protected]:e2b-dev/api.git
+fi
+
+# Get the current branch
+BRANCH=$(git rev-parse --abbrev-ref HEAD)
+
+# Fetch the latest changes
+git fetch api
+
+# Checkout the latest changes
+git checkout api/main -B temp_api_branch
+
+# Create a temporary branch to store the spec
+git subtree split --prefix=spec -b temp_spec_branch
+
+# Checkout the branch
+git checkout "$BRANCH"
+
+# Merge the changes
+git subtree merge --prefix=spec temp_spec_branch --squash
+
+# Remove the temporary branch
+git branch -D temp_spec_branch
+git branch -D temp_api_branch