total pesticide dernier prelèvement #87
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🔄 Synchronize Production DB to storage | |
on: | |
push: | |
branches: [ "main" ] | |
paths: [ "dbt_/**" ] | |
schedule: | |
# Execute pipeline every 1st and 15th of the month at 10:00 AM | |
- cron: '0 10 1,15 * *' | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: 'Raison de la synchronisation' | |
required: true | |
type: string | |
default: 'Mise à jour manuelle de la base de données' | |
env: | |
ENV: prod | |
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }} | |
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }} | |
jobs: | |
sync_prod_database: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install a specific version of uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
version: ">=0.4.0" | |
- name: Install dependencies | |
run: uv sync | |
- name: Download production database from Storage | |
run: | | |
uv run pipelines/run.py run download_database | |
- name: Update production database | |
run: | | |
uv run pipelines/run.py run build_database --refresh-type all --check-update | |
- name: Install dbt dependencies | |
run: | | |
cd dbt_ | |
uv run dbt deps || { echo "dbt deps failed"; exit 1; } | |
- name: Create tables/views in dbt | |
run: | | |
cd dbt_ | |
uv run dbt build || { echo "dbt build failed"; exit 1; } | |
- name: Upload production database to Storage | |
run: | | |
uv run pipelines/run.py run upload_database | |
- name: Generate geo_json, convert geo_json to pmtiles and update pmtiles to Storage | |
run: | | |
uv pip install .[pmtiles] | |
uv run pipelines/run.py run generate_pmtiles --upload | |
- name: Create Issue if Failed | |
if: failure() | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: context.repo.name, | |
title: '❌ Échec de la synchronisation de la base de données', | |
body: `La synchronisation de la base de données a échoué.\n\nVoir les détails : ${context.serverUrl}/${context.repo.owner}/${context.repo.name}/actions/runs/${context.runId}`, | |
labels: ['bug', 'database'] | |
}) |