on master help sign in
Merge pull request #2500 from dalf/github-action-data
34de715Alexandre Flament
.github/workflows/data-update.ymlnew file+67
@@ -0,0 +1,67 @@
1+name: "Update searx.data"
2+on:
3+ schedule:
4+ - cron: "37 13 * * 0"
5+
6+jobs:
7+ updateData:
8+ name: Update data
9+ runs-on: ubuntu-20.04
10+ if: env.DATA_PR_TOKEN != null
11+ steps:
12+ - name: Checkout
13+ uses: actions/checkout@v2
14+
15+ - name: Install Ubuntu packages
16+ run: |
17+ sudo ./utils/searx.sh install packages
18+
19+ - name: Set up Python
20+ uses: actions/setup-python@v2
21+ with:
22+ python-version: '3.9'
23+ architecture: 'x64'
24+
25+ - name: Cache Python dependencies
26+ id: cache-python
27+ uses: actions/cache@v2
28+ with:
29+ path: ./local
30+ key: python-${{ matrix.os }}-3.9-${{ hashFiles('requirements*.txt', 'setup.py') }}
31+
32+ - name: Install Python dependencies
33+ if: steps.cache-python.outputs.cache-hit != 'true'
34+ run: |
35+ make V=1 install
36+
37+ - name: Fetch data
38+ run: |
39+ source local/py3/bin/activate
40+ python utils/fetch_firefox_version.py
41+ python utils/fetch_languages.py
42+ python utils/fetch_ahmia_blacklist.py
43+ python utils/fetch_wikidata_units.py
44+ # python utils/fetch_currencies.py
45+
46+ - name: Create Pull Request
47+ id: cpr
48+ uses: peter-evans/create-pull-request@v3
49+ with:
50+ token: ${{ secrets.DATA_PR_TOKEN }}
51+ commit-message: Update searx.data
52+ committer: searx-bot <noreply@github.com>
53+ author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
54+ signoff: false
55+ branch: automatic-update-data
56+ delete-branch: true
57+ title: 'Update searx.data'
58+ body: |
59+ Update searx.data
60+ labels: |
61+ data
62+ draft: false
63+
64+ - name: Check outputs
65+ run: |
66+ echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
67+ echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
utils/fetch_languages.py+4−3
@@ -6,18 +6,19 @@
6# are written in current directory to avoid overwriting in case something goes wrong.
6# are written in current directory to avoid overwriting in case something goes wrong.
7
7
8import json
8import json
9+from pathlib import Path
9from pprint import pformat
10from pprint import pformat
10from sys import path
11from sys import path
11from babel import Locale, UnknownLocaleError
12from babel import Locale, UnknownLocaleError
12from babel.languages import get_global
13from babel.languages import get_global
13
14
14path.append('../searx') # noqa
15path.append('../searx') # noqa
15−from searx import settings
16+from searx import settings, searx_dir
16from searx.engines import initialize_engines, engines
17from searx.engines import initialize_engines, engines
17
18
18# Output files.
19# Output files.
19−engines_languages_file = 'engines_languages.json'
20+engines_languages_file = Path(searx_dir) / 'data' / 'engines_languages.json'
20−languages_file = 'languages.py'
21+languages_file = Path(searx_dir) / 'languages.py'
21
22
22
23
23# Fetchs supported languages for each engine and writes json file with those.
24# Fetchs supported languages for each engine and writes json file with those.