-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (49 loc) · 2.08 KB
/
Copy pathdev.yml
File metadata and controls
61 lines (49 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Workflow Dev
on:
push:
branches:
- 'development'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout du code
uses: actions/checkout@v3
- name: Installation de Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Installation des dépendances
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint flask flask_sqlalchemy flask_migrate psycopg2-binary
- name: Vérification de PostgreSQL
run: |
echo "Attente de PostgreSQL..."
until PGPASSWORD=${{ secrets.POSTGRES_PASSWORD_DEV }} psql -h 51.255.51.83 -p 5433 -U dev_user -d dev_db -c '\q'; do
sleep 1
done
echo "PostgreSQL est prêt."
- name: Définir la variable DATABASE_URL
run: |
echo "DATABASE_URL=postgresql://dev_user:${{ secrets.POSTGRES_PASSWORD_DEV }}@51.255.51.83:5433/dev_db" >> $GITHUB_ENV
- name: Exécution de Pylint
run: pylint $(find . -name "*.py" -not -path "./migrations/*") --disable=W
- name: Vérifier et appliquer les migrations si besoin
run: |
echo "Vérification des changements dans les modèles..."
flask db migrate -m "Migration auto" || true
if git diff --quiet --exit-code -- migrations/versions; then
echo "ucun changement détecté. Pas de migration à appliquer."
else
echo "Migration détectée. Application..."
flask db upgrade
echo "💾 Commit et push de la migration"
git config --local user.email "ci@depsec.org"
git config --local user.name "CI Migrations"
git add migrations/versions/*.py
git commit -m "Migration générée automatiquement"
git remote set-url origin https://${{ github.actor }}:${{ secrets.TOKEN }}@github.com/${{ github.repository }}
git push origin ${{ github.ref_name }}
fi