mirror of
https://github.com/Alex38Lyon/Synthese-PSM_LARRA.git
synced 2026-09-30 07:21:55 +00:00
Modify GitHub Actions to include SQL file checks
Updated workflow to check for changes in both SHP and SQL files. Adjusted conditions for executing subsequent steps based on changes detected.
This commit is contained in:
@@ -5,6 +5,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- 'Outputs/SHP/*.shp'
|
- 'Outputs/SHP/*.shp'
|
||||||
|
- 'Outputs/DB_Synthese-PSM_LARRA.sql'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -24,12 +25,36 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 2. Vérification SHP
|
# 2. Vérification des fichiers SHP et SQL modifiés
|
||||||
|
# ou lancement manuel
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Check SHP changes
|
- name: Check SHP and SQL changes
|
||||||
id: changed
|
id: changed
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
echo "========================================"
|
||||||
|
echo "VÉRIFICATION DES MODIFICATIONS"
|
||||||
|
echo "========================================"
|
||||||
|
|
||||||
|
# --------------------------------------------------------
|
||||||
|
# Lancement manuel
|
||||||
|
# --------------------------------------------------------
|
||||||
|
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
|
||||||
|
echo "Workflow lancé manuellement."
|
||||||
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "manual=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "shp=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "sql=true" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "========================================"
|
||||||
|
echo "Recherche des fichiers modifiés"
|
||||||
|
echo "========================================"
|
||||||
|
|
||||||
|
# --------------------------------------------------------
|
||||||
|
# SHP ajoutés ou modifiés
|
||||||
|
# --------------------------------------------------------
|
||||||
SHP_FILES=$(git diff-tree \
|
SHP_FILES=$(git diff-tree \
|
||||||
--no-commit-id \
|
--no-commit-id \
|
||||||
--name-only \
|
--name-only \
|
||||||
@@ -38,25 +63,87 @@ jobs:
|
|||||||
"$GITHUB_SHA" \
|
"$GITHUB_SHA" \
|
||||||
-- 'Outputs/SHP/*.shp')
|
-- 'Outputs/SHP/*.shp')
|
||||||
|
|
||||||
echo "SHP ajoutés/modifiés :"
|
# --------------------------------------------------------
|
||||||
echo "$SHP_FILES"
|
# SQL ajouté ou modifié
|
||||||
|
# --------------------------------------------------------
|
||||||
|
SQL_FILE="Outputs/DB_Synthese-PSM_LARRA.sql"
|
||||||
|
SQL_CHANGED=$(git diff-tree \
|
||||||
|
--no-commit-id \
|
||||||
|
--name-only \
|
||||||
|
--diff-filter=AM \
|
||||||
|
-r \
|
||||||
|
"$GITHUB_SHA" \
|
||||||
|
-- "$SQL_FILE")
|
||||||
|
|
||||||
|
# --------------------------------------------------------
|
||||||
|
# Affichage
|
||||||
|
# --------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "SHP ajoutés/modifiés :"
|
||||||
if [ -n "$SHP_FILES" ]; then
|
if [ -n "$SHP_FILES" ]; then
|
||||||
|
echo "$SHP_FILES"
|
||||||
echo "shp=true" >> "$GITHUB_OUTPUT"
|
echo "shp=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
|
echo "Aucun"
|
||||||
echo "shp=false" >> "$GITHUB_OUTPUT"
|
echo "shp=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "SQL ajouté/modifié :"
|
||||||
|
if [ -n "$SQL_CHANGED" ]; then
|
||||||
|
echo "$SQL_CHANGED"
|
||||||
|
echo "sql=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "Aucun"
|
||||||
|
echo "sql=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --------------------------------------------------------
|
||||||
|
# Décision de poursuivre
|
||||||
|
# --------------------------------------------------------
|
||||||
|
if [ -n "$SHP_FILES" ] || [ -n "$SQL_CHANGED" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "SHP ou SQL ajouté/modifié : CONTINUER"
|
||||||
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "Aucun SHP ni SQL ajouté/modifié."
|
||||||
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "manual=false" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 3. Arrêt si suppression uniquement
|
# 3.1 Arrêt si aucun SHP/SQL et pas de lancement manuel
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Stop if no SHP added or modified
|
- name: Stop if no SHP or SQL changes
|
||||||
if: steps.changed.outputs.shp != 'true'
|
if: steps.changed.outputs.changed != 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "Aucun SHP ajouté ou modifié."
|
echo "Aucun SHP ou SQL ajouté/modifié."
|
||||||
echo "Arrêt du workflow."
|
echo "Arrêt du workflow."
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 3.2 Vérification de la base SQL
|
||||||
|
# ============================================================
|
||||||
|
- name: Check SQL database
|
||||||
|
if: steps.changed.outputs.changed == 'true'
|
||||||
|
shell: bash -el {0}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
echo "========================================"
|
||||||
|
echo "CHECK DATABASE"
|
||||||
|
echo "========================================"
|
||||||
|
SQL_FILE="Outputs/DB_Synthese-PSM_LARRA.sql"
|
||||||
|
if [ ! -f "$SQL_FILE" ]; then
|
||||||
|
echo "ERREUR : fichier SQL introuvable :"
|
||||||
|
echo "$SQL_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Base SQL trouvée :"
|
||||||
|
ls -lh "$SQL_FILE"
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 4. Micromamba
|
# 4. Micromamba
|
||||||
# IMPORTANT :
|
# IMPORTANT :
|
||||||
@@ -64,7 +151,7 @@ jobs:
|
|||||||
# GDAL sera fourni par notre package précompilé.
|
# GDAL sera fourni par notre package précompilé.
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Setup Micromamba
|
- name: Setup Micromamba
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
uses: mamba-org/setup-micromamba@v3.2.1
|
uses: mamba-org/setup-micromamba@v3.2.1
|
||||||
with:
|
with:
|
||||||
environment-name: pyThtoQgis
|
environment-name: pyThtoQgis
|
||||||
@@ -89,7 +176,7 @@ jobs:
|
|||||||
# 5. Informations environnement
|
# 5. Informations environnement
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Environment information
|
- name: Environment information
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
@@ -105,7 +192,7 @@ jobs:
|
|||||||
# 6. Téléchargement package GDAL
|
# 6. Téléchargement package GDAL
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Download GDAL + SFCGAL package
|
- name: Download GDAL + SFCGAL package
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
@@ -133,7 +220,7 @@ jobs:
|
|||||||
# 7. Installation package GDAL
|
# 7. Installation package GDAL
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Installation GDAL package
|
- name: Installation GDAL package
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -264,7 +351,7 @@ jobs:
|
|||||||
# 8. Vérification GDAL
|
# 8. Vérification GDAL
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Check GDAL
|
- name: Check GDAL
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -291,7 +378,7 @@ jobs:
|
|||||||
# 9. Vérification SFCGAL
|
# 9. Vérification SFCGAL
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Check SFCGAL linkage
|
- name: Check SFCGAL linkage
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -305,7 +392,7 @@ jobs:
|
|||||||
# 10. Test SFCGAL
|
# 10. Test SFCGAL
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Test SFCGAL via OGR
|
- name: Test SFCGAL via OGR
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
python - <<'PY'
|
python - <<'PY'
|
||||||
@@ -346,7 +433,7 @@ jobs:
|
|||||||
# 11. Dépendances Python
|
# 11. Dépendances Python
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.sql == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
@@ -358,7 +445,7 @@ jobs:
|
|||||||
# 12. Affichage des SHP
|
# 12. Affichage des SHP
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: List SHP input files
|
- name: List SHP input files
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
@@ -374,7 +461,7 @@ jobs:
|
|||||||
# 13. Exécution pyThtoQgis
|
# 13. Exécution pyThtoQgis
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Run pyThtoQgis
|
- name: Run pyThtoQgis
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -385,43 +472,10 @@ jobs:
|
|||||||
python pyThtoQgis.py --folder "../../Outputs/SHP/"
|
python pyThtoQgis.py --folder "../../Outputs/SHP/"
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 14. Vérification base SQL
|
# 14. Exécution pyThStat
|
||||||
# ============================================================
|
|
||||||
- name: Check SQL database
|
|
||||||
if: steps.changed.outputs.shp == 'true'
|
|
||||||
shell: bash -el {0}
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
echo "========================================"
|
|
||||||
echo "CHECK DATABASE"
|
|
||||||
echo "========================================"
|
|
||||||
|
|
||||||
echo "========================================"
|
|
||||||
echo "Find SQL"
|
|
||||||
echo "========================================"
|
|
||||||
ls -l
|
|
||||||
echo "========================================"
|
|
||||||
find Outputs \
|
|
||||||
-maxdepth 1 \
|
|
||||||
-type f \
|
|
||||||
-name "*.sql" \
|
|
||||||
-print
|
|
||||||
|
|
||||||
SQL_FILE="Outputs/DB_Synthese-PSM_LARRA.sql"
|
|
||||||
|
|
||||||
if [ ! -f "$SQL_FILE" ]; then
|
|
||||||
echo "ERREUR : fichier SQL introuvable :"
|
|
||||||
echo "$SQL_FILE"
|
|
||||||
# exit 1
|
|
||||||
fi
|
|
||||||
echo "Base SQL trouvée :"
|
|
||||||
ls -lh "$SQL_FILE"
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# 15. Exécution pyThStat
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Run pyThStat
|
- name: Run pyThStat
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -435,10 +489,10 @@ jobs:
|
|||||||
python pythStat.py --file "../../Outputs/DB_Synthese-PSM_LARRA.sql"
|
python pythStat.py --file "../../Outputs/DB_Synthese-PSM_LARRA.sql"
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 16. Fichiers produits
|
# 15. Fichiers produits
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Show generated files
|
- name: Show generated files
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.sql == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
@@ -449,15 +503,13 @@ jobs:
|
|||||||
git diff --stat
|
git diff --stat
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 17. Commit
|
# 16. Commit
|
||||||
# ============================================================
|
# ============================================================
|
||||||
- name: Commit generated files
|
- name: Commit generated files
|
||||||
if: steps.changed.outputs.shp == 'true'
|
if: steps.changed.outputs.shp == 'true' || steps.changed.outputs.sql == 'true' || steps.changed.outputs.manual == 'true'
|
||||||
uses: stefanzweifel/git-auto-commit-action@v7
|
uses: stefanzweifel/git-auto-commit-action@v7
|
||||||
with:
|
with:
|
||||||
commit_message: "Auto-generate outputs from SHP"
|
commit_message: "Auto-generate outputs from ScriptPython"
|
||||||
commit_user_name: "github-actions[bot]"
|
commit_user_name: "github-actions[bot]"
|
||||||
|
|
||||||
commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com"
|
commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
|
commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
|
||||||
|
|||||||
Reference in New Issue
Block a user