diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..cd144aa --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: Account Backup + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + schedule: + - cron: '0 */4 * * *' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Run the script + run: | + python main.py + - name: Update the file + run: | + git config --global user.name 'dhakal0kushal' + git config --global user.email 'dhakalkushal371@gmail.com@users.noreply.github.com' + git add . + git commit -m "Automated report" + git push + diff --git a/main.py b/main.py index b579600..ba9598f 100644 --- a/main.py +++ b/main.py @@ -37,7 +37,7 @@ def run(): """ now = datetime.now() - date_time = now.strftime('%Y-%m-%d-%H:%M:%S') + date_time = now.strftime('%Y-%m-%d-%H_%M_%S') file_path = os.path.join(ACCOUNT_BACKUPS_DIR, f'{date_time}.json') data = format_results(fetch_account_data()) verify_results(data=data) @@ -58,7 +58,7 @@ def verify_results(*, data): if total == MAX_POINT_VALUE: print('\nValid') else: - print('\nInvalid') + raise Exception("Invalid!!") if __name__ == '__main__':