Coder Social home page Coder Social logo

matthieu-rolland / distribution-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prestashop/distribution-api

1.0 0.0 0.0 5.57 MB

API to inform about core & module releases

Home Page: https://api.prestashop-project.org/

License: MIT License

PHP 99.66% Dockerfile 0.34%

distribution-api's Introduction

PrestaShop OpenSource API

Installation

  1. Run composer install
  2. Get a Github token (with write rights on the repository defined in config/parameters.yaml: https://github.com/settings/tokens/new?description=PrestaShopOpenSourceAPI&scopes=repo
  3. Create a bucket on GCP and download a Service Account key file

Usage

Requirements

You should have 3 environment variables defined:

  • TOKEN - The Github token required to use the Github API
  • GOOGLE_APPLICATION_CREDENTIALS - Path to the json file previously downloaded containing the authentication information to use GCP
  • BUCKET_NAME - The name of the bucket where json files should be uploaded

Main commands

Download the module's main files

$ ./bin/console downloadNativeModuleFiles

This will download the main file of the module so the app can extract the module's version and the PrestaShop versions compliance. It will also download the zip release of the module if it isn't already in the GCP bucket, so it can be added later by the command uploadAssets

Download PrestaShop's releases

$ ./bin/console downloadNewPrestaShopReleases

This will download PrestaShop's zip release and the associated xml file so the app can extract the PHP version compatibilities. (Only releases that are not already in the GCP bucket, or having incomplete associated json file (missing xml file for instance) are downloaded).

Update modules' config file

$ ./bin/console updateModuleConfigFiles

This will add new versions of module with their PrestaShop versions compatibility to the repository defined for the key module_list_repository in config/parameters.yaml

Generate json files

$ ./bin/console generateJson

This will generate the different json files to be publicly exposed in the public/json/ folder

Upload generated files to a GCP bucket

$ ./bin/console uploadAssets

This will upload the generated json files as well as the new PrestaShop and module's releases to the GCP bucket

Utility commands

Check that there is no error on the PrestaShop & module's repositories:

$ ./bin/console checkRepos

Clean the folder(s) passed as an argument:

$ ./bin/console clean all|json|modules|prestashop

Everything together

$ ./bin/console run

This will execute the 6 following commands:

  • clean all
  • downloadNativeModuleFiles
  • downloadNewPrestaShopReleases
  • updateModuleConfigFiles
  • generateJson
  • uploadAssets

Docker

To use this tool with Docker, you have to:

  • Build the image: $ docker build -t distribution-api .
  • Run it with the command you want: $ docker run --rm -v /path/to/credentials.json:/app/credentials.json -e TOKEN=your_github_token -e BUCKET_NAME=distribution-api -e GOOGLE_APPLICATION_CREDENTIALS=credentials.json distribution-api run

Endpoints

http://<domain.to.public.folder>/modules/<prestashop_version>
Returns last version of every native module compatible with the specified PrestaShop version

http://<domain.to.public.folder>/prestashop
Returns every PrestaShop versions

http://<domain.to.public.folder>/prestashop/<channel>
Returns the latest version of the specified channel
<channel> can be: stable, rc or beta

Environments

There are 3 targeted environment at the moment:

  • Integration: integration-api.prestashop-project.org
  • Preproduction: preprod-api.prestashop-project.org
  • Production: api.prestashop-project.org

Those edge URLs are hosted at the Cloudflare level, proxyfying the origin GCP Storage.

Architecture

alt text

Workflow

Being on github we'll use the github workflow as follow:

alt text

As you can see from the schema above

  • add the label "integration-deployment" to a Pull Request to trigger the deployment of the integration environment and be able to test it
  • merge a Pull Request against branch main to trigger the deployment of the preprod environment and be able to test it
  • publish a GitHub release to trigger the deployment of the production environment

Warning about CI

The integration-deployment label, when added to a Pull Request, will run the Integration Workflow which relies on GitHub secrets. These secrets are not available for forks, which means if you add the integration-deployment label to a Pull Request whose branch is on a fork, it will fail.

If you wish to test a Pull Request using the integration-deployment label, the branch must be on the upstream repository.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.