diff --git a/.github/workflows/update-softwares.yml b/.github/workflows/update-softwares.yml new file mode 100644 index 0000000..dc88cff --- /dev/null +++ b/.github/workflows/update-softwares.yml @@ -0,0 +1,25 @@ +on: + schedule: + - cron: '15 */1 * * *' + +jobs: + update-softwares: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 🐍 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies 📦 + run: | + pip install -r cloud-data/requirements.txt + - run: python -m cloud-data.importer + env: + GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + - name: Commit changes + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + message: '🤖 Update softwares' + add: 'softwares/*' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2f7274f..b3650d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ scripts/vendor +/repositories +/temp_repositories +*.pyc +.DS_Store \ No newline at end of file diff --git a/AUTHORS b/AUTHORS index 62ccc14..c866011 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,3 @@ -Copyright (c) 2018-2021 Presidenza del Consiglio dei Ministri +Copyright (c) 2018-2022 Presidenza del Consiglio dei Ministri The version control system provides attribution for specific lines of code. diff --git a/README.md b/README.md index a45cdfc..a07bc5e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,6 @@ build. ## License -Copyright (c) 2018-2021 - Presidenza del Consiglio dei Ministri +Copyright (c) 2018-2022 - Presidenza del Consiglio dei Ministri The source code is released under the BSD license (SPDX code: `BSD-3-Clause`). diff --git a/cloud-data/importer.py b/cloud-data/importer.py new file mode 100644 index 0000000..eb4015f --- /dev/null +++ b/cloud-data/importer.py @@ -0,0 +1,80 @@ +import os +import pathlib +import shutil +import yaml +import json +from github import Github +from git import Repo + + +REPO_FOLDER = "repositories" +TEMP_REPO_FOLDER = "temp_repositories" +SOFTWARES_FOLDER = "softwares" + +pathlib.Path(REPO_FOLDER).mkdir(parents=True, exist_ok=True) + +github_client = Github(os.environ.get("GH_ACCESS_TOKEN")) + + +def _write_json_file(software_name, payload): + dest = os.path.join(SOFTWARES_FOLDER, f"{software_name}.json") + with open(dest, "w", encoding="utf-8") as f: + json.dump(payload, f, ensure_ascii=False, indent=4) + + +def _get_data_from_software(base_directory, software, provider, softwares): + desc_yml_path = os.path.join(base_directory, "desc.yml") + if os.path.isfile(desc_yml_path): + if software not in softwares: + softwares[software] = {} + softwares[software]["providers"] = {} + if provider not in softwares[software]["providers"]: + softwares[software]["providers"][provider] = {} + with open(desc_yml_path, "r") as stream: + try: + yaml_data = yaml.safe_load(stream) + softwares[software]["providers"][provider] = yaml_data[ + "deployment_option" + ] + except yaml.YAMLError as exc: + print(exc) + + +def fetch_providers(): + softwares = {} + if os.path.exists(TEMP_REPO_FOLDER): + shutil.rmtree(TEMP_REPO_FOLDER) + if os.path.exists(SOFTWARES_FOLDER): + shutil.rmtree(SOFTWARES_FOLDER) + pathlib.Path(TEMP_REPO_FOLDER).mkdir(parents=True, exist_ok=True) + pathlib.Path(SOFTWARES_FOLDER).mkdir(parents=True, exist_ok=True) + for repo in github_client.search_repositories("org:w0rkb3nch"): + if repo.name.startswith("cloud-"): + print(f"🗃 Cloning {repo.clone_url}..", end="") + software_direcotry = os.path.join(REPO_FOLDER, repo.name) + temp_software_directory = os.path.join(TEMP_REPO_FOLDER, repo.name) + Repo.clone_from(repo.clone_url, temp_software_directory) + shutil.rmtree(os.path.join(temp_software_directory, ".git")) + shutil.copytree( + temp_software_directory, software_direcotry, dirs_exist_ok=True + ) + print("Done!") + print(f"📃 Fetching data from {repo.name}..", end="") + for software in os.listdir(software_direcotry): + _get_data_from_software( + os.path.join(software_direcotry, software), + software, + repo.name, + softwares, + ) + print("Done!") + + softwares_collection = [] + for software_name, software_data in softwares.items(): + software = {"slug": software_name, **software_data} + _write_json_file(software_name, software) + softwares_collection.append(software) + _write_json_file("all", softwares_collection) + + +fetch_providers() diff --git a/cloud-data/requirements.txt b/cloud-data/requirements.txt new file mode 100644 index 0000000..0f224d0 --- /dev/null +++ b/cloud-data/requirements.txt @@ -0,0 +1,3 @@ +PyGithub==1.55 +GitPython==3.1.27 +PyYAML==6.0 diff --git a/softwares/all.json b/softwares/all.json new file mode 100644 index 0000000..c948e2c --- /dev/null +++ b/softwares/all.json @@ -0,0 +1,151 @@ +[ + { + "slug": "m_it-vvfosprojects-sovvf", + "providers": { + "cloud-general": { + "single_tier": { + "generic_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "### Template Single Tier\nPuoi eseguire la soluzione {{include.page.publiccode.name}} in base al consumo, avviandola e interrompendola a livello di codice. Questa soluzione è preconfigurata e pronta per l'uso su una qualsiasi delle piattaforme seguenti.\n- Distribuisci rapidamente le tue applicazioni nel cloud e rendile disponibili online\n- Pagamento a consumo, paghi solo per le risorse che utilizzi\n" + }, + "launch_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "### Lancia un template Single Tier\nScegli una piattaforma tra quelle proposte per lanciare un template Single Tier che si adatti alle tue esigenze.\n" + }, + "links": [ + { + "title": { + "en": "Link 1", + "it": "Collegamento 1" + }, + "url": "/it/piattaforme" + } + ] + }, + "multi_tier": { + "generic_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "Il mio ruolo includeva la **supervisione** del team di marketing e la guida della **pubblicità**.\n" + }, + "launch_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "Il mio ruolo includeva la **supervisione** del team di marketing e la guida della **pubblicità**.\n" + }, + "links": [ + { + "title": { + "en": "Link 1", + "it": "Collegamento 1" + }, + "url": "/it/piattaforme" + } + ] + }, + "docker": { + "generic_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "Il mio ruolo includeva la **supervisione** del team di marketing e la guida della **pubblicità**.\n" + }, + "launch_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "Il mio ruolo includeva la **supervisione** del team di marketing e la guida della **pubblicità**.\n" + }, + "links": [ + { + "title": { + "en": "Link 1", + "it": "Collegamento 1" + }, + "url": "/it/piattaforme" + } + ] + } + }, + "cloud-amazon": { + "single_tier": { + "solution_name": "AWS", + "deploy_url": "https://www.vigilfuoco.it/", + "demo": "https://gitlab.it", + "op_level": 4 + }, + "multi_tier": { + "solution_name": "AWS", + "deploy_url": "https://www.vigilfuoco.it/", + "demo": "https://www.vigilfuoco.it/", + "op_level": 4 + } + }, + "cloud-local": { + "docker": { + "command": "docker-compose up" + } + }, + "cloud-google": { + "single_tier": { + "solution_name": "Google Cloud", + "deploy_url": "https://vvff.it", + "demo": "https://vvff.it", + "op_level": 4 + }, + "multi_tier": { + "solution_name": "Google Cloud", + "deploy_url": "https://vvff.it", + "demo": "https://vvff.it", + "op_level": 4 + } + } + } + }, + { + "slug": "gitlab", + "providers": { + "cloud-amazon": { + "single_tier": { + "deploy_url": "https://gitlab.it", + "demo": "https://gitlab.it", + "monthly_cost": "5 dollars", + "op_level": 4 + }, + "multi_tier": { + "deploy_url": "https://gitlab.com", + "demo": "https://gitlab.com", + "monthly_cost": "3 dollars", + "op_level": 4 + } + } + } + }, + { + "slug": "sigla", + "providers": { + "cloud-amazon": { + "single_tier": { + "deploy_url": "https://developersitalia.it", + "demo": "https://developersitalia.it", + "monthly_cost": "35 dollars", + "op_level": 2 + }, + "multi_tier": { + "deploy_url": "https://amazon.com", + "demo": "https://amazon.com", + "monthly_cost": "15 dollars", + "op_level": 2 + } + }, + "cloud-google": { + "single_tier": { + "deploy_url": "https://developersitalia.it", + "demo": "https://developersitalia.it", + "monthly_cost": "32 dollars", + "op_level": 2 + }, + "multi_tier": { + "deploy_url": "https://google.com", + "demo": "https://google.com", + "monthly_cost": "12 dollars", + "op_level": 5 + } + } + } + } +] \ No newline at end of file diff --git a/softwares/gitlab.json b/softwares/gitlab.json new file mode 100644 index 0000000..17b6e59 --- /dev/null +++ b/softwares/gitlab.json @@ -0,0 +1,19 @@ +{ + "slug": "gitlab", + "providers": { + "cloud-amazon": { + "single_tier": { + "deploy_url": "https://gitlab.it", + "demo": "https://gitlab.it", + "monthly_cost": "5 dollars", + "op_level": 4 + }, + "multi_tier": { + "deploy_url": "https://gitlab.com", + "demo": "https://gitlab.com", + "monthly_cost": "3 dollars", + "op_level": 4 + } + } + } +} \ No newline at end of file diff --git a/softwares/m_it-vvfosprojects-sovvf.json b/softwares/m_it-vvfosprojects-sovvf.json new file mode 100644 index 0000000..d4c6392 --- /dev/null +++ b/softwares/m_it-vvfosprojects-sovvf.json @@ -0,0 +1,97 @@ +{ + "slug": "m_it-vvfosprojects-sovvf", + "providers": { + "cloud-general": { + "single_tier": { + "generic_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "### Template Single Tier\nPuoi eseguire la soluzione {{include.page.publiccode.name}} in base al consumo, avviandola e interrompendola a livello di codice. Questa soluzione è preconfigurata e pronta per l'uso su una qualsiasi delle piattaforme seguenti.\n- Distribuisci rapidamente le tue applicazioni nel cloud e rendile disponibili online\n- Pagamento a consumo, paghi solo per le risorse che utilizzi\n" + }, + "launch_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "### Lancia un template Single Tier\nScegli una piattaforma tra quelle proposte per lanciare un template Single Tier che si adatti alle tue esigenze.\n" + }, + "links": [ + { + "title": { + "en": "Link 1", + "it": "Collegamento 1" + }, + "url": "/it/piattaforme" + } + ] + }, + "multi_tier": { + "generic_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "Il mio ruolo includeva la **supervisione** del team di marketing e la guida della **pubblicità**.\n" + }, + "launch_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "Il mio ruolo includeva la **supervisione** del team di marketing e la guida della **pubblicità**.\n" + }, + "links": [ + { + "title": { + "en": "Link 1", + "it": "Collegamento 1" + }, + "url": "/it/piattaforme" + } + ] + }, + "docker": { + "generic_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "Il mio ruolo includeva la **supervisione** del team di marketing e la guida della **pubblicità**.\n" + }, + "launch_description": { + "en": "My role included **supervising** the marketing team and leading **publicity**.\n", + "it": "Il mio ruolo includeva la **supervisione** del team di marketing e la guida della **pubblicità**.\n" + }, + "links": [ + { + "title": { + "en": "Link 1", + "it": "Collegamento 1" + }, + "url": "/it/piattaforme" + } + ] + } + }, + "cloud-amazon": { + "single_tier": { + "solution_name": "AWS", + "deploy_url": "https://www.vigilfuoco.it/", + "demo": "https://gitlab.it", + "op_level": 4 + }, + "multi_tier": { + "solution_name": "AWS", + "deploy_url": "https://www.vigilfuoco.it/", + "demo": "https://www.vigilfuoco.it/", + "op_level": 4 + } + }, + "cloud-local": { + "docker": { + "command": "docker-compose up" + } + }, + "cloud-google": { + "single_tier": { + "solution_name": "Google Cloud", + "deploy_url": "https://vvff.it", + "demo": "https://vvff.it", + "op_level": 4 + }, + "multi_tier": { + "solution_name": "Google Cloud", + "deploy_url": "https://vvff.it", + "demo": "https://vvff.it", + "op_level": 4 + } + } + } +} \ No newline at end of file diff --git a/softwares/sigla.json b/softwares/sigla.json new file mode 100644 index 0000000..74d07bf --- /dev/null +++ b/softwares/sigla.json @@ -0,0 +1,33 @@ +{ + "slug": "sigla", + "providers": { + "cloud-amazon": { + "single_tier": { + "deploy_url": "https://developersitalia.it", + "demo": "https://developersitalia.it", + "monthly_cost": "35 dollars", + "op_level": 2 + }, + "multi_tier": { + "deploy_url": "https://amazon.com", + "demo": "https://amazon.com", + "monthly_cost": "15 dollars", + "op_level": 2 + } + }, + "cloud-google": { + "single_tier": { + "deploy_url": "https://developersitalia.it", + "demo": "https://developersitalia.it", + "monthly_cost": "32 dollars", + "op_level": 2 + }, + "multi_tier": { + "deploy_url": "https://google.com", + "demo": "https://google.com", + "monthly_cost": "12 dollars", + "op_level": 5 + } + } + } +} \ No newline at end of file