Skip to content

Merge pull request #26 from 16bravo/feature/data_update_yml #1

Merge pull request #26 from 16bravo/feature/data_update_yml

Merge pull request #26 from 16bravo/feature/data_update_yml #1

name: DB Update
on:
push:
branches:
- main
jobs:
init_db:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Check if database exists
id: check-db
run: |
if [ -f data/BravoRanking.db ]; then
echo "Database exists already. OK for update."
echo "::set-output name=update_ok::true"
else
echo "Database does not exist. KO for update."
echo "::set-output name=update_ok::false"
fi
- name: Install dependencies
if: steps.check-db.outputs.update_ok == 'true'
run: pip install -r requirements.txt
- name: Create .kaggle directory
if: steps.check-db.outputs.update_ok == 'true'
run: mkdir -p /home/runner/.kaggle
- name: Set up Kaggle credentials
if: steps.check-db.outputs.update_ok == 'true'
run: echo "$KAGGLE_JSON" > /home/runner/.kaggle/kaggle.json && chmod 600 /home/runner/.kaggle/kaggle.json
env:
KAGGLE_JSON: ${{ secrets.KAGGLE_JSON }}
- name: Run update script
if: steps.check-db.outputs.init_required == 'true'
run: python scripts/db_update.py
- name: Commit changes
if: steps.check-db.outputs.init_required == 'true'
run: |
git config --global user.email "c.bravo2@yahoo.fr"
git config --global user.name "16bravo"
git add data/BravoRanking.db
git commit -m "Database Update"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}