Deploy #68
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| default_dict: | |
| description: 'Generate the default dictionary' | |
| default: true | |
| required: false | |
| type: boolean | |
| misc_dict: | |
| description: 'Generate the misc dictionaries' | |
| default: false | |
| required: false | |
| type: boolean | |
| full_dict: | |
| description: 'Generate the full dictionary' | |
| default: false | |
| required: false | |
| type: boolean | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout dex2xml | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Setup and install dependencies | |
| run: | | |
| mkdir db | |
| sudo tar -xvzf kindlegen_linux_2.6_i386_v2_9.tar.gz -C /usr/bin/ kindlegen | |
| python -m pip install --upgrade pip | |
| pip install pymysql | |
| sudo ls -l /var/lib/mysql | |
| sudo chown -R $(whoami):$(whoami) /var/lib/mysql | |
| - name: Cache MySQL Data Directory | |
| id: mysql-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: /var/lib/mysql | |
| key: mysql-data-cache | |
| restore-keys: mysql-data-cache | |
| - name: Restore MySQL permissions | |
| if: steps.mysql-cache.outputs.cache-hit == 'true' | |
| continue-on-error: true | |
| run: | | |
| sudo ls -l /var/lib/mysql | |
| sudo chown -R mysql:mysql /var/lib/mysql | |
| - name: Start MySQL | |
| run: sudo systemctl start mysql | |
| continue-on-error: true | |
| - name: logs | |
| continue-on-error: true | |
| run: | | |
| sudo ls -l /var/lib/mysql | |
| # systemctl status mysql.service | |
| journalctl -xeu mysql.service | |
| - name: Download database and setup database | |
| if: steps.mysql-cache.outputs.cache-hit != 'true' | |
| run: | | |
| wget -O ./db/dex-database.sql.gz https://dexonline.ro/static/download/dex-database.sql.gz -nv | |
| mysql -e 'create database dexonline charset utf8mb4 collate utf8mb4_romanian_ci' -uroot -proot | |
| zcat ./db/dex-database.sql.gz | mysql -uroot -proot dexonline | |
| - name: Print database stats | |
| run: | | |
| mysql -e "use dexonline; select id, shortName, concat(name, ', ', year) as source, (select count(lexicon) from Definition d where d.status = 0 and d.sourceId = s.id) as defcount, canDistribute from Source s order by id;" -uroot -proot | |
| - name: Generate the default dictionary | |
| if: ${{ inputs.default_dict == true }} | |
| run: | | |
| # python dex2xml.py --batch --password root --sources 40 65 --temp_files --outputfile "DEXonline short" | |
| python dex2xml.py --batch --password root --sources 27 40 41 65 --outputfile "DEXonline DEX" | |
| - name: Generate the misc dictionaries | |
| if: ${{ inputs.misc_dict == true }} | |
| run: | | |
| python dex2xml.py --batch --password root --sources 12 --outputfile "DEXonline DER" | |
| python dex2xml.py --batch --password root --sources 19 --outputfile "DEXonline DOOM2" | |
| python dex2xml.py --batch --password root --sources 21 55 --outputfile "DEXonline MDN" | |
| python dex2xml.py --batch --password root --sources 26 --outputfile "DEXonline Argou" | |
| python dex2xml.py --batch --password root --sources 53 --outputfile "DEXonline MDA2" | |
| python dex2xml.py --batch --password root --sources 23 --outputfile "DEXonline DLRLV" | |
| - name: Generate the full dictionary | |
| if: ${{ inputs.full_dict == true }} | |
| run: | | |
| python dex2xml.py --batch --password root --sources 27 40 65 34 36 22 23 26 21 55 --outputfile "DEXonline full" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dictionaries | |
| path: | | |
| *.* | |
| !db/* | |
| - name: Stop MySQL and ensure all processes exited | |
| run: | | |
| sudo systemctl stop mysql | |
| sleep 2 | |
| ps aux | grep mysql | |
| - name: Fix MySQL permissions for caching | |
| run: sudo chown -R $(whoami):$(whoami) /var/lib/mysql |