Skip to content

Commit

Permalink
Add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
kamicut committed May 30, 2024
1 parent c07e8b1 commit 776a7ed
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Generate and Publish Database

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
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.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Download XML zip file
run: |
curl -O http://ratings.fide.com/download/players_list_xml.zip
- name: Unzip XML file
run: |
unzip players_list_xml.zip -d ./
mv players_list.xml players.xml
- name: Generate SQLite database
run: |
python players.py players.xml players.db
- name: Deploy to Fly.io using Datasette
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
datasette publish fly players.db --app="fide-players" -m metadata.json --token $FLY_API_TOKEN
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@
</div>
<script src="main.js"></script>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function fideSelector() {

// Convert URLs to HTTPS
convertToHttps(url) {
if (url.startsWith("http:")) {
if (url && url.startsWith("http:")) {
return url.replace("http://", "https://");
}
return url;
Expand Down Expand Up @@ -116,7 +116,7 @@ function fideSelector() {
url.searchParams.append("country__exact", this.selectedCountry);
}
if (this.playerSearch) {
url.searchParams.append("name__contains", this.playerSearch);
url.searchParams.append("_search", this.playerSearch);
}
if (this.sortAsc) {
url.searchParams.append("_sort", this.sortKey);
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
tqdm==4.66.4
datasette
datasette-publish-fly

0 comments on commit 776a7ed

Please sign in to comment.