stefanzweifel / git-auto-commit-action

Automatically commit and push changed files back to GitHub with this GitHub Action for the 80% use case.
MIT License
1.98k stars 227 forks source link

Deletion in diff caused by auto-commit? #133

Closed chnuessli closed 3 years ago

chnuessli commented 3 years ago

Version of the Action v4.0.0

Describe the bug Sometimes when i run the action, the diff says the whole json file is deleted. I want to find out if the problem is in auto-commit or the overpass api that delivers no result. In my opinion, if there's no answer in the result from overpass, the actions fails. The other way, maybe there's a problem in the diff and therefore, the action thinks it's an empty json file. I dont know if this is a bug, but maybe you can help me out with this.

To Reproduce Steps to reproduce the behavior: Check this two commits: https://github.com/chnuessli/defi_archive/commit/46f0f42ec9dbeb99adb22adaddf037ceecccd523 https://github.com/chnuessli/defi_archive/commit/be890a48dfb766099dff0191840339bc58f71dfb

See the diff in here:

Run stefanzweifel/git-auto-commit-action@v4
Started: bash /home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/entrypoint.sh
INPUT_REPOSITORY value: .
INPUT_BRANCH value: 
M   data/defis_switzerland.geojson
Your branch is up to date with 'origin/main'.
INPUT_FILE_PATTERN: .
INPUT_COMMIT_OPTIONS: 
INPUT_COMMIT_USER_NAME: chnuessli
INPUT_COMMIT_USER_EMAIL: chrigi@chnuessli.ch
INPUT_COMMIT_MESSAGE: Update overpass query results
INPUT_COMMIT_AUTHOR: GitHub Action Bot <chrigi@chnuessli.ch>
[main 46f0f42] Update overpass query results
 Author: GitHub Action Bot <chrigi@chnuessli.ch>
 1 file changed, 6 insertions(+), 86442 deletions(-)
 rewrite data/defis_switzerland.geojson (99%)
INPUT_TAGGING_MESSAGE: 
No tagging message supplied. No tag will be added.
INPUT_PUSH_OPTIONS: 
To https://github.com/chnuessli/defi_archive
   86c9fb6..46f0f42  main -> main

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Used Workflow

name: Get data from Overpass

on:
  schedule:
  #- cron:  '00 6 * * *' # run every day at 06:00 UTC
  - cron:  '*/60 * * * *' # run every hour
  workflow_dispatch: ~

jobs:
  query_overpass:
    runs-on: ubuntu-18.04
    continue-on-error: false
    timeout-minutes: 10

    steps:
    - uses: actions/checkout@v2

    - name: Set up Python 3.7
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
        sudo npm install -g osmtogeojson

    - name: Get data from Overpass API
      run: |
        ./run_queries.sh

    - uses: stefanzweifel/git-auto-commit-action@v4
      with:
        commit_message: Update overpass query results
        commit_user_name: chnuessli
        commit_user_email: chrigi@chnuessli.ch
        commit_author: GitHub Action Bot <chrigi@chnuessli.ch>

Additional context If there's not a problem with your code, feel free to close the issue

stefanzweifel commented 3 years ago

This sound like a problem which occurs when the overpass API doesn't return a result. git-auto-commit is pretty dumb and just commits everything that has changed. It doesn't look into the files or checks if a file has been deleted and would then abort or throw an Exception.

Maybe you can try and check on this line, if the response has any results? If no, then throw an Exception. https://github.com/chnuessli/defi_archive/blob/main/overpass_query.py#L23

(Btw, what a fantastic project you have there with defikarte.ch! And the idea of archiving the data through GitHub 💯)

chnuessli commented 3 years ago

Okay thank you. I will try to put in a check if the file is empty. thanks for the roses, feel free to contribute by yourself. any help or improvements are very welcome. merry christmas!