SteGONZALEZ commited on
Commit
eddf5fe
·
1 Parent(s): 6d68c0d

modification procédure CD

Browse files
Files changed (2) hide show
  1. .coverage +0 -0
  2. .github/workflows/cd.yml +37 -10
.coverage CHANGED
Binary files a/.coverage and b/.coverage differ
 
.github/workflows/cd.yml CHANGED
@@ -4,7 +4,6 @@ on:
4
  push:
5
  branches: ["main"]
6
 
7
-
8
  jobs:
9
  test:
10
  name: tests_CD
@@ -17,7 +16,7 @@ jobs:
17
  - name: Set up Python
18
  uses: actions/setup-python@v5
19
  with:
20
- python-version: "3.13"
21
 
22
  - name: Install Poetry
23
  uses: snok/install-poetry@v1
@@ -26,16 +25,17 @@ jobs:
26
  virtualenvs-create: true
27
  virtualenvs-in-project: true
28
 
29
- - name: Install dependencies
30
- run: poetry install --no-interaction
31
 
32
- - name: Run tests (SQLite)
33
  env:
34
  API_KEY: "ci-test-key"
35
- DATABASE_URL: "sqlite+pysqlite:///:memory:"
36
  run: poetry run pytest -q
37
 
38
  build-and-push:
 
39
  runs-on: ubuntu-latest
40
  needs: test
41
 
@@ -47,8 +47,9 @@ jobs:
47
  - name: Checkout
48
  uses: actions/checkout@v4
49
 
50
- - name: Set image name (lowercase)
51
- run: echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
 
52
 
53
  - name: Log in to GHCR
54
  uses: docker/login-action@v3
@@ -63,5 +64,31 @@ jobs:
63
  context: .
64
  push: true
65
  tags: |
66
- ${{ env.IMAGE_NAME }}:latest
67
- ${{ env.IMAGE_NAME }}:${{ github.sha }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  push:
5
  branches: ["main"]
6
 
 
7
  jobs:
8
  test:
9
  name: tests_CD
 
16
  - name: Set up Python
17
  uses: actions/setup-python@v5
18
  with:
19
+ python-version: "3.12"
20
 
21
  - name: Install Poetry
22
  uses: snok/install-poetry@v1
 
25
  virtualenvs-create: true
26
  virtualenvs-in-project: true
27
 
28
+ - name: Install dependencies (with dev)
29
+ run: poetry install --no-interaction --with dev
30
 
31
+ - name: Run tests (SQLite file)
32
  env:
33
  API_KEY: "ci-test-key"
34
+ DATABASE_URL: "sqlite+pysqlite:////tmp/test.db"
35
  run: poetry run pytest -q
36
 
37
  build-and-push:
38
+ name: build_and_push_GHCR
39
  runs-on: ubuntu-latest
40
  needs: test
41
 
 
47
  - name: Checkout
48
  uses: actions/checkout@v4
49
 
50
+ - name: Compute image name (lowercase)
51
+ id: vars
52
+ run: echo "image_name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
53
 
54
  - name: Log in to GHCR
55
  uses: docker/login-action@v3
 
64
  context: .
65
  push: true
66
  tags: |
67
+ ${{ steps.vars.outputs.image_name }}:latest
68
+ ${{ steps.vars.outputs.image_name }}:${{ github.sha }}
69
+
70
+ deploy-huggingface:
71
+ name: deploy_to_huggingface
72
+ runs-on: ubuntu-latest
73
+ needs: build-and-push
74
+
75
+ steps:
76
+ - name: Checkout
77
+ uses: actions/checkout@v4
78
+ with:
79
+ fetch-depth: 0
80
+
81
+ - name: Push to Hugging Face Space (force)
82
+ env:
83
+ HF_TOKEN: "${{ secrets.HF_TOKEN }}"
84
+ run: |
85
+ set -euo pipefail
86
+ git config --global user.email "ci@github.com"
87
+ git config --global user.name "github-actions"
88
+
89
+ # évite l'erreur si le remote existe déjà
90
+ git remote remove hf 2>/dev/null || true
91
+ git remote add hf https://huggingface.co/spaces/SteGONZALEZ/technova-api
92
+
93
+ # push authentifié vers HF (avec token) + force comme tu fais d'habitude
94
+ git push --force https://SteGONZALEZ:${HF_TOKEN}@huggingface.co/spaces/SteGONZALEZ/technova-api main