name: Update data
on:
  workflow_dispatch:
  schedule:
    - cron:  '15 0 * * *'
jobs:
  scrape:
    name: Update data
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: |
          wget -O data-full.json "https://www.overpass-api.de/api/interpreter?data=%0A%09%09%09%5Bout%3Ajson%5D%5Btimeout%3A300%5D%3B%0A%09%09%09(%0A%09%09%09%20%20node%5B%22seamark%3Alight%3Asequence%22%5D(-90%2C-180%2C90%2C180)%3B%0A%09%09%09%20%20node%5B%22seamark%3Alight%3A1%3Asequence%22%5D(-90%2C-180%2C90%2C180)%3B%0A%09%09%09%20%20way%5B%22seamark%3Alight%3Asequence%22%5D(-90%2C-180%2C90%2C180)%3B%0A%09%09%09%20%20way%5B%22seamark%3Alight%3A1%3Asequence%22%5D(-90%2C-180%2C90%2C180)%3B%0A%09%09%09)%3B%0A%09%09%09out%20body%3B%0A%09%09%09%3E%3B%0A%09%09%09out%20skel%20qt%3B%0A%09%09"
      - name: Commit the data
        uses: nick-invision/retry@v2
        with:
          timeout_seconds: 10
          max_attempts: 5
          command: |
            git config --global user.name 'Geodienst (Github Actions)'
            git config --global user.email 'geodienst-accounts@rug.nl'
            git add data-full.json
            git commit -am "Updating the data via Github action"
            git push
