From 4f426d5e41592e1cc2abe33acc7677254a1470e0 Mon Sep 17 00:00:00 2001 From: benjaminpilia Date: Thu, 7 Nov 2024 18:39:37 +0100 Subject: [PATCH] Fix pipeline (#17) Co-authored-by: Benjamin PILIA --- .github/workflows/build_and_deploy.yml | 20 +++++++++++++------- api/Dockerfile | 1 + api/pyproject.toml | 7 ++++++- docs/packaging.md | 13 ++++++++++++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index d3dd35a..3ec61ba 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -5,6 +5,10 @@ on: branches: - main +env: + IMAGE_NAME: ghcr.io/${{ github.repository }}/franceservices-backend + IMAGE_TAG: ${{ github.sha }} + # TODO: add tests # Gitlab old code: # test:pyalbert: @@ -48,13 +52,15 @@ jobs: build-and-push: name: Build and push from ${{ github.ref_name }}/${{ github.sha }} runs-on: ubuntu-latest - env: - IMAGE_NAME: ghcr.io/${{ github.repository }}/api - IMAGE_TAG: ${{ github.sha }} + outputs: + commit_title: ${{ steps.get_head_commit_title.outputs.title }} steps: - name: Checkout repository uses: actions/checkout@v4 + - id: get_head_commit_title + run: echo "title=$(git log --format=%B -n 1 HEAD | head -n 1)" >> $GITHUB_OUTPUT + - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: @@ -85,9 +91,9 @@ jobs: RESPONSE="$(curl --request POST \ --form token=${{ secrets.GITLAB_CI_TOKEN }} \ --form ref=main \ - --form 'variables[pipeline_name]=${{ github.event.repository.name }} - ${{ github.event.head_commit.message }}' \ - --form 'variables[docker_image_tag]=latest' \ - --form 'variables[application_to_deploy]=${{ github.event.repository.name }}' \ + --form 'variables[pipeline_name]=${{ github.event.repository.name }} - ${{ needs.build-and-push.outputs.commit_title }}' \ + --form 'variables[docker_image_tag]=${{ env.IMAGE_TAG }}' \ + --form 'variables[application_to_deploy]=albert-france-services-backend' \ --form 'variables[deployment_environment]=dev' \ 'https://gitlab.com/api/v4/projects/58117805/trigger/pipeline')" @@ -96,4 +102,4 @@ jobs: else echo $RESPONSE exit 1 - fi + fi \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile index b083356..78a410f 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -13,4 +13,5 @@ RUN pip install --no-cache-dir --default-timeout=100 . # add the rest of the code ADD . . + CMD ["bash", "start.sh"] diff --git a/api/pyproject.toml b/api/pyproject.toml index ef5b697..6f1e954 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -23,7 +23,12 @@ dependencies = [ "sqlalchemy-utils==0.41.2", "uvicorn==0.30.1", "lz4==4.3.3", - "pyalbert==0.7.4", + "pyalbert==0.7.7", + "itsdangerous==2.2.0", + "redis==5.1.1", + "authlib==1.3.2", + "pyjwt==2.9.0", + "faker==30.8.0" ] # Tests diff --git a/docs/packaging.md b/docs/packaging.md index e73ff30..3e40269 100644 --- a/docs/packaging.md +++ b/docs/packaging.md @@ -1,7 +1,18 @@ -How to build and deploy pyalbert +# Comment build et publier une nouvelle version de PyAAlbert +Le module `pyalbert` est publié dabs les dépôts PyPi. Il faut incrémenter manuellement toute nouvelle version de `pyalbert`. +Pour cela, modifier: +- la variable `__version__` dans `pyalbert/_version.py` +- la variable `version` dans le `pyproject.toml` racine + +Puis lancer: ```sh python -m pip install build twine python -m build twine upload dist/* ``` + + +# Mise à jour du module dans l'API +Pour que l'API utilise la nouvelle version du module, modifier la valeur du module `pyalbert==0.x.y` (section `dependencies`) dans le `pyproject.toml` du dossier api. +