Skip to content

Litteralis Import

Litteralis Import #227

name: Litteralis Import
on:
workflow_dispatch:
inputs:
enabled_orgs:
description: "Organisations à intégrer (format : array JSON)"
required: false
default: null
type: string
communication_enabled_orgs:
description: "Organisations à intégrer via le flux Communication (format : array JSON)"
required: false
default: null
type: string
schedule:
- cron: '15 16 * * 1-5' # Voir https://crontab.guru/ : du lundi au vendredi à 16h15 GMT
jobs:
import:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Scalingo CLI
run: curl -O https://cli-dl.scalingo.com/install && bash install
- name: Install SSH key
# Credit: https://stackoverflow.com/a/69234389
run: |
mkdir -p ~/.ssh
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.GH_SCALINGO_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
- name: Add Scalingo as a known host
run: |
ssh-keyscan -H ssh.osc-fr1.scalingo.com >> ~/.ssh/known_hosts
- name: Init environment variables
run: |
echo "DATABASE_URL=${{ secrets.APP_LITTERALIS_IMPORT_DATABASE_URL }}" >> .env.local
echo "BDTOPO_2025_DATABASE_URL=${{ secrets.BDTOPO_2025_DATABASE_URL }}" >> .env.local
echo "EMAIL_SUPPORT=${{ vars.EMAIL_SUPPORT }}" >> .env.local
echo "MAILER_DSN=${{ secrets.MAILER_DSN }}" >> .env.local
# Deal with JSON quotes
printf "APP_LITTERALIS_ENABLED_ORGS='%s'\n" '${{ vars.APP_LITTERALIS_ENABLED_ORGS }}' >> .env.local
printf "APP_LITTERALIS_COMMUNICATION_ENABLED_ORGS='%s'\n" '${{ vars.APP_LITTERALIS_COMMUNICATION_ENABLED_ORGS }}' >> .env.local
- name: Override enabled orgs if defined by input
if: ${{ inputs.enabled_orgs }}
run: |
# Deal with JSON quotes
printf "APP_LITTERALIS_ENABLED_ORGS='%s'\n" '${{ inputs.enabled_orgs }}' >> .env.local
- name: Override communication enabled orgs if defined by input
if: ${{ inputs.communication_enabled_orgs }}
run: |
# Deal with JSON quotes
printf "APP_LITTERALIS_COMMUNICATION_ENABLED_ORGS='%s'\n" '${{ inputs.communication_enabled_orgs }}' >> .env.local
- name: Init organization environment variables
run: |
./tools/ci_litteralis_init_org_env_vars.py GHA_SECRETS "APP_LITTERALIS_ORG_*"
env:
GHA_SECRETS: ${{ toJson(secrets) }}
- name: Run import
run: make ci_litteralis_import BIN_PHP="php" BIN_CONSOLE="php bin/console" BIN_COMPOSER="composer"
- name: Run communication import
if: ${{ vars.APP_LITTERALIS_COMMUNICATION_ENABLED_ORGS != '' && vars.APP_LITTERALIS_COMMUNICATION_ENABLED_ORGS != '[]' }}
run: make ci_litteralis_import_communication BIN_PHP="php" BIN_CONSOLE="php bin/console"
- name: Get log file path
id: logfile
if: ${{ !cancelled() }}
run:
echo "path=$(find log/litteralis -type f -name '*.log' | head -n 1)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: litteralis_logfile
path: ${{ steps.logfile.outputs.path }}
retention-days: 21