-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (66 loc) · 3.21 KB
/
aligulac-import.yaml
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
on:
workflow_dispatch:
schedule:
- cron: '0 20 * * 5'
#permissions:
# contents: write
jobs:
import_aligulac:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: "--no-clean --no-sync --set wal_level=minimal --set max_wal_senders=0 --set fsync=off --set full_page_writes=off --set synchronous_commit=off --set synchronous_commit=off --set bgwriter_lru_maxpages=0 --set archive_mode=off --set work_mem=256MB --set maintenance_work_mem=256MB --set shared_buffers=512MB"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Install postgres client & rg
run: sudo apt-get install -y postgresql-client ripgrep
- name: Postgres client version
run: psql --version
- name: Install yq
run: sudo snap install yq --channel=v4/stable
- name: Check out repository code
uses: actions/checkout@v4
- name: Download Aligulac dump
run: wget -qO- http://static.aligulac.com/aligulac.sql.gz | gzip -d > aligulac.sql
- name: Modify dump for faster import
run: rg --passthru "^CREATE TABLE" -r "CREATE UNLOGGED TABLE" aligulac.sql > aligulac2.sql
- name: Modify dump for faster import 2
run: rg --passthru "^CREATE INDEX group" -r "--CREATE INDEX group" aligulac2.sql > aligulac3.sql
- name: grep changes
run: rg UNLOGGED aligulac3.sql && rg -C 1 "CREATE INDEX" aligulac3.sql
- name: Import Aligulac DB
run: PGPASSWORD=postgres psql -h localhost -p 5432 -d postgres -U postgres -f aligulac3.sql
- name: Import GuessTheSC2Pro Fixes
run: PGPASSWORD=postgres psql -h localhost -p 5432 -d postgres -U postgres -f db_import/data-fixup.sql
- name: Export player data
run: PGPASSWORD=postgres psql -h localhost -p 5432 -d postgres -U postgres --csv -f db_import/top500-earnings.sql > result.csv
- name: Convert to JSON
run: yq result.csv -p=csv -o=json > players.json
- name: Truncated 400 Player Json
run: yq '.[0:400]' players.json -o=json > players400.json && yq 'length' players400.json
- name: Truncated 250 Player Json
run: yq '.[0:250]' players.json -o=json > players250.json && yq 'length' players250.json
- name: Turn Json files into JS
run: sed -i -e '1s/^/var players = /' -e '$a;' players400.json && sed -i -e '1s/^/var players = /' -e '$a;' players250.json
- name: Rename to js
run: mv players400.json players400.js && mv players250.json players250.js
- name: Move to correct location
run: mv players400.js assets/js/players400.js && mv players250.js assets/js/players250.js
- name: Git Status
run: git config --global diff.algorithm patience && git status && git diff assets/js/players250.js
- name: Commit changes
run: |
git config --global user.name 'GH Action Bot'
git config --global user.email 'tobijdce@users.noreply.github.com'
git add assets/js/
git commit -m "Automated Player Update"
git push