diff --git a/.env b/.env new file mode 100644 index 0000000..d138aac --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +GITEA_ACCESS_TOKEN=528ed6363ba47884c05235cff9ba47e38b4201d5 +GITEA_USERNAME=hoangvv +GITEA_PASSWORD=smartyourlife +GITEA_HOST = https://git.nextzenos.com/api/v1 diff --git a/.gitignore b/.gitignore index adf8f72..10e460e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ # Go workspace file go.work +venv/ +*.zip diff --git a/bifrost.json b/bifrost.json index 43a4c72..7be94e5 100644 --- a/bifrost.json +++ b/bifrost.json @@ -1,4 +1,13 @@ { + "id": "bifrost", + "name": "Bifrost", + "description": "Bifrost is a platform for building and deploying applications.", + "deployment": { + "type": "native" + }, + "installation": { + "host_type": "local" + }, "apps": [ { "key": "nextzenos", @@ -38,45 +47,46 @@ ], "tags": [ { - "key": "Website", - "name": "Website", + "key": "server-panel", + "name": "Server Panel", "sort": 1 }, { - "key": "Database", + "key": "database", "name": "Database", "sort": 2 }, { - "key": "Server", - "name": "Web Server", + "key": "firewall", + "name": "FireWall", "sort": 3 }, { - "key": "Runtime", - "name": "Runtime", + "key": "tool", + "name": "Utility", "sort": 4 }, { - "key": "Tool", - "name": "Utility", + "key": "vpn", + "name": "VPN", "sort": 5 }, { - "key": "DevTool", - "name": "Development tool", - "sort": 10 + "key": "nas", + "name": "NAS", + "sort": 5 }, { - "key": "Middleware", - "name": "Middleware", - "sort": 12 + "key": "cli", + "name": "CLI", + "sort": 6 }, { - "key": "Local", - "name": "Local", - "sort": 99 + "key": "api", + "name": "API", + "sort": 6 } ], + "version": "1.0.0", "lastModified": 1746671214 } \ No newline at end of file diff --git a/nextcloud.json b/nextcloud.json index a8462a7..3f0a42a 100644 --- a/nextcloud.json +++ b/nextcloud.json @@ -6,9 +6,9 @@ "deployment": { "type": "docker" }, - "location": { - "host_type": "local", - "installation_path": "/opt/bifrost/apps/nextcloud" + "installation": { + "host_type": "local" }, + "tags": [], "lastModified": 1746671214 } \ No newline at end of file diff --git a/nextdns.json b/nextdns.json index 8132708..8a0796f 100644 --- a/nextdns.json +++ b/nextdns.json @@ -6,9 +6,10 @@ "deployment": { "type": "native" }, - "location": { + "installation": { "host_type": "remote", "host": "10.0.0.1" }, + "tags": [], "lastModified": 1746671214 } \ No newline at end of file diff --git a/nextfirewall.json b/nextfirewall.json index 5737429..c36cb1e 100644 --- a/nextfirewall.json +++ b/nextfirewall.json @@ -6,9 +6,10 @@ "deployment": { "type": "native" }, - "location": { + "installation": { "host_type": "remote", "host": "10.0.0.1" }, + "tags": [], "lastModified": 1746671214 } \ No newline at end of file diff --git a/nextnas.json b/nextnas.json index 90514d7..b5dc82c 100644 --- a/nextnas.json +++ b/nextnas.json @@ -6,8 +6,9 @@ "deployment": { "type": "native" }, - "location": { + "locinstallationation": { "host_type": "local" }, + "tags": [], "lastModified": 1746671214 } \ No newline at end of file diff --git a/nextvpn.json b/nextvpn.json index 9403ae1..31c5a4a 100644 --- a/nextvpn.json +++ b/nextvpn.json @@ -6,9 +6,9 @@ "deployment": { "type": "docker" }, - "location": { - "host_type": "local", - "installation_path": "/opt/bifrost/apps/nextvpn" + "installation": { + "host_type": "local" }, + "tags": [], "lastModified": 1746671214 } \ No newline at end of file diff --git a/nextweb.json b/nextweb.json index b905a1b..6924ac3 100644 --- a/nextweb.json +++ b/nextweb.json @@ -6,10 +6,10 @@ "deployment": { "type": "docker" }, - "location": { - "host_type": "local", - "installation_path": "/opt/bifrost/apps/nextweb" + "installation": { + "host_type": "local" }, "apps": [], + "tags": [], "lastModified": 1746671214 } \ No newline at end of file diff --git a/nextzenos.json b/nextzenos.json index 6f77342..e78426d 100644 --- a/nextzenos.json +++ b/nextzenos.json @@ -1,14 +1,15 @@ { "id": "nextzenos", - "name": "NextZenOS", + "name": "NextzenOS", "version": "1.4", "description": "", "deployment": { "type": "native" }, - "location": { + "installation": { "host_type": "local" }, "apps": [], + "tags": [], "lastModified": 1746671214 } \ No newline at end of file diff --git a/registry.mk b/registry.mk index 88f927b..07eb470 100644 --- a/registry.mk +++ b/registry.mk @@ -1,6 +1,8 @@ REGISTRY_PATH = $(shell pwd)/registry REGISTRY_REPO = git.nextzenos.com/CDN/bifrost-registry.git -update_registry: +RELEASE_UID = 8845 +PYTHON = $(REGISTRY_PATH)/venv/bin/python +update_registry: package_registry upload_registry ( cd $(REGISTRY_PATH) && \ @read -p "Enter your commit message: " commit_msg; \ git pull https://$(GIT_USER):$(GIT_PASS)@$(REGISTRY_REPO) || true; \ @@ -11,3 +13,6 @@ update_registry: package_registry: (cd $(REGISTRY_PATH) && \ zip -r registry.zip *.json -x .gitignore .git .mk) + +upload_registry: + $(PYTHON) $(REGISTRY_PATH)/scripts/main.py diff --git a/requirement.txt b/requirement.txt new file mode 100644 index 0000000..0a7efc4 --- /dev/null +++ b/requirement.txt @@ -0,0 +1,2 @@ +python-dotenv ; python_version > '3.10' +git+https://github.com/dblueai/giteapy.git ; python_version > '3.10' \ No newline at end of file diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/__pycache__/config.cpython-312.pyc b/scripts/__pycache__/config.cpython-312.pyc new file mode 100644 index 0000000..4e63097 Binary files /dev/null and b/scripts/__pycache__/config.cpython-312.pyc differ diff --git a/scripts/__pycache__/gitea.cpython-312.pyc b/scripts/__pycache__/gitea.cpython-312.pyc new file mode 100644 index 0000000..b26f080 Binary files /dev/null and b/scripts/__pycache__/gitea.cpython-312.pyc differ diff --git a/scripts/gitea/__init__.py b/scripts/gitea/__init__.py new file mode 100644 index 0000000..3a8999e --- /dev/null +++ b/scripts/gitea/__init__.py @@ -0,0 +1,4 @@ +from .config import GiteaConfig +from .api import GiteaApi + +__all__ = ["GiteaConfig", "GiteaApi"] diff --git a/scripts/gitea/__pycache__/__init__.cpython-312.pyc b/scripts/gitea/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..fbeb561 Binary files /dev/null and b/scripts/gitea/__pycache__/__init__.cpython-312.pyc differ diff --git a/scripts/gitea/__pycache__/api.cpython-312.pyc b/scripts/gitea/__pycache__/api.cpython-312.pyc new file mode 100644 index 0000000..6a647ca Binary files /dev/null and b/scripts/gitea/__pycache__/api.cpython-312.pyc differ diff --git a/scripts/gitea/__pycache__/config.cpython-312.pyc b/scripts/gitea/__pycache__/config.cpython-312.pyc new file mode 100644 index 0000000..d28e121 Binary files /dev/null and b/scripts/gitea/__pycache__/config.cpython-312.pyc differ diff --git a/scripts/gitea/api.py b/scripts/gitea/api.py new file mode 100644 index 0000000..c16aa6a --- /dev/null +++ b/scripts/gitea/api.py @@ -0,0 +1,26 @@ +import giteapy +from .config import GiteaConfig + + +class GiteaApi: + + def __init__(self): + self.config = GiteaConfig().configuration + + def admin_gitea_instance(self): + return giteapy.AdminApi(giteapy.ApiClient(self.config)) + + def repo_gitea_instance(self): + return giteapy.RepositoryApi(giteapy.ApiClient(self.config)) + + def user_gitea_instance(self): + return giteapy.UserApi(giteapy.ApiClient(self.config)) + + def org_gitea_instance(self): + return giteapy.OrganizationApi(giteapy.ApiClient(self.config)) + + def misc_gitea_instance(self): + return giteapy.MiscellaneousApi(giteapy.ApiClient(self.config)) + + def issue_gitea_instance(self): + return giteapy.IssueApi(giteapy.ApiClient(self.config)) diff --git a/scripts/gitea/config.py b/scripts/gitea/config.py new file mode 100644 index 0000000..9ad8ab2 --- /dev/null +++ b/scripts/gitea/config.py @@ -0,0 +1,14 @@ +import os +from dotenv import load_dotenv +import giteapy + +# Automatically look for .env in the project root +load_dotenv() + + +class GiteaConfig: + def __init__(self): + self.configuration = giteapy.Configuration() + self.configuration.host = os.getenv("GITEA_HOST") + self.configuration.api_key["Authorization"] = os.getenv("GITEA_ACCESS_TOKEN") + self.configuration.api_key_prefix["Authorization"] = "Bearer" diff --git a/scripts/main.py b/scripts/main.py new file mode 100644 index 0000000..1a2c8ef --- /dev/null +++ b/scripts/main.py @@ -0,0 +1,47 @@ +from gitea.api import GiteaApi +from gitea.config import GiteaConfig +import giteapy +import os +import json + + +def main(): + gitea_instance = GiteaApi() + admin_instance = gitea_instance.admin_gitea_instance() + repo_instance = gitea_instance.repo_gitea_instance() + + # Parameters + owner = "CDN" # Owner of the repository + repo = "bifrost-registry" # Repository name + release_id = 8845 # The ID of the release to attach to + attachment_path = ( + "/root/dev/Bifrost/registry/registry.zip" # Path to the file you want to upload + ) + get_release_response = repo_instance.repo_get_release( + owner=owner, + repo=repo, + id=release_id, # Release ID + ) + assets = get_release_response.assets + attachment_id = None + for asset in assets: + if asset.name == "registry.zip": + attachment_id = asset.id + repo_instance.repo_delete_release_attachment( + owner=owner, + repo=repo, + id=release_id, # Release ID + attachment_id=attachment_id, + ) + create_response = repo_instance.repo_create_release_attachment( + owner=owner, + repo=repo, + id=release_id, # Release ID + attachment=attachment_path, + name=os.path.basename(attachment_path), # Filename for the attachment + ) + print(create_response) + + +if __name__ == "__main__": + main()