-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (72 loc) · 2.86 KB
/
010_init_database.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: DB Initialisation
on:
push:
branches:
- main
jobs:
init_db:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Restore dependency cache
uses: actions/cache@v2
with:
path: |
~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
- 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. No need for init."
echo "::set-output name=init_required::false"
else
echo "Database does not exist. Init needed."
echo "::set-output name=init_required::true"
fi
- name: Install dependencies
if: steps.check-db.outputs.init_required == 'true'
run: pip install -r requirements.txt
- name: Create .kaggle directory
if: steps.check-db.outputs.init_required == 'true'
run: mkdir -p /home/runner/.kaggle
- name: Set up Kaggle credentials
if: steps.check-db.outputs.init_required == '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 Teams Table creation script
if: steps.check-db.outputs.init_required == 'true'
run: python scripts/010_DB_Initialisation/011_Create_Insert_Teams.py
- name: Run Rankings Table creation script
if: steps.check-db.outputs.init_required == 'true'
run: python scripts/010_DB_Initialisation/012_Create_Rankings.py
- name: Run Matches Table creation script
if: steps.check-db.outputs.init_required == 'true'
run: python scripts/010_DB_Initialisation/013_Create_Matches.py
- name: Commit changes
if: steps.check-db.outputs.init_required == 'true'
run: |
git config --global user.email "${{ secrets.GIT_EMAIL }}"
git config --global user.name "${{ secrets.GIT_USERNAME }}"
if git diff --quiet data/BravoRanking.db; then
echo "No changes in BravoRanking.db. Skipping commit."
else
git add data/BravoRanking.db
git commit -m "Database Creation"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sauvegarder le cache des dépendances
uses: actions/cache@v2
with:
path: |
~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}