diff --git a/.github/workflows/sync_databases.yml b/.github/workflows/sync_databases.yml index c41dfa803..385898ddc 100644 --- a/.github/workflows/sync_databases.yml +++ b/.github/workflows/sync_databases.yml @@ -8,6 +8,7 @@ env: DUPLICATE_SOURCE_APP: ${{ secrets.DUPLICATE_SOURCE_APP }} DUPLICATE_ADDON_KIND: postgresql PREPROD_DATABASE_URL: ${{ secrets.PREPROD_DATABASE_URL }} + RUN: scalingo --app "${DUPLICATE_SOURCE_APP}" run defaults: run: @@ -26,13 +27,13 @@ jobs: run: | # Login to Scalingo, using the token stored in `DUPLICATE_API_TOKEN`: scalingo login --api-token "${DUPLICATE_API_TOKEN}" + - name: Install Scalingo CLI + run: ${RUN} install-scalingo-cli + - name: Install postgres tools + run: ${RUN} dbclient-fetcher "${DUPLICATE_ADDON_KIND}" - name: Generate database archive run: | archive_name="backup.tar.gz" - - # Install additional tools to interact with the database: - scalingo --app "${DUPLICATE_SOURCE_APP}" run dbclient-fetcher "${DUPLICATE_ADDON_KIND}" - # Retrieve the addon id: addon_id="$( scalingo --app "${DUPLICATE_SOURCE_APP}" addons \ | grep "${DUPLICATE_ADDON_KIND}" \ @@ -40,9 +41,8 @@ jobs: | tr -d " " )" # Download the latest backup available for the specified addon: - scalingo --app "${DUPLICATE_SOURCE_APP}" --addon "${addon_id}" \ + ${RUN} scalingo --app "${DUPLICATE_SOURCE_APP}" --addon "${addon_id}" \ backups-download --output "${archive_name}" - - name: Restore the database run: | # Get the name of the backup file: @@ -51,8 +51,8 @@ jobs: | cut -d "/" -f 2 )" # Extract the archive containing the downloaded backup: - scalingo run --app "${DUPLICATE_SOURCE_APP}" tar --extract --verbose --file="${archive_name}" --directory="/app/" + tar --extract --verbose --file="${archive_name}" --directory="/app/" # Restore the data: - scalingo run --app "${DUPLICATE_SOURCE_APP}" pg_restore --clean --if-exists --no-owner --no-privileges --no-comments \ + pg_restore --clean --if-exists --no-owner --no-privileges --no-comments \ --dbname "${DATABASE_URL}" "/app/${backup_file_name}"