version: '{build}'

environment:
  access_token:
    secure: wxAvRgqg8ErfZm05ESB2zJxjwhny9wS0kRgK8TBDl2UeXnA06tqZPtNkwfRJc9SE

clone_depth: 1
test: off

install:
  - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://sqlite.org/2024/sqlite-tools-win-x64-3450300.zip ; exit 0"
  - 7z x sqlite-tools-win-x64-3450300.zip
  - cp -r locales dumps
  
build_script:
  - FOR /R dumps %%f in (*.cdb) DO sqlite3.exe %%f .dump > %%f.sql

after_build:
  - ps: |
      if(-not $env:appveyor_pull_request_number -and $env:APPVEYOR_REPO_BRANCH -eq 'master') {
        $env:GIT_REDIRECT_STDERR = '2>&1'
        git fetch --depth 1 origin dump:dump
        git checkout dump
        Copy-Item -Path .\dumps\* -Destination .\locales\ -Recurse -Force
        git config --global user.email $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL
        git config --global user.name $env:APPVEYOR_REPO_COMMIT_AUTHOR
        try { git commit -a -m $env:APPVEYOR_REPO_COMMIT_MESSAGE } catch { Write-Output "Nothing Changed" }
        git config --global credential.helper store
        Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
        git push origin dump
      }

cache:
  - sqlite-tools-win-x64-3450300.zip
