diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index fe406b0..0000000 --- a/.drone.yml +++ /dev/null @@ -1,82 +0,0 @@ -kind: pipeline -name: build-and-deploy -type: docker - -platform: - os: linux - arch: arm64 - - -steps: - - name: docker-build-and-push - image: thegeeklab/drone-docker-buildx # Absurd that this isn't offered as first-party! - privileged: true - settings: - # Consider testing with this if the cache-to arguments don't help! - # args: - # - BUILDKIT_INLINE_CACHE=1 - cache_from: - - "gitea.scubbo.org/${DRONE_REPO}:${DRONE_BRANCH}" - cache_to: - # https://docs.docker.com/build/cache/backends/registry/ - # `mode=max` necessary in order to cache intermediate stages - # - # https://github.com/go-gitea/gitea/issues/28973#issuecomment-1961859655 - # Some parameters are necessary in order to make the push to gitea succeed - # - # Another reference: - # https://github.com/thegeeklab/drone-docker-buildx/issues/47 - - "type=registry,ref=gitea.scubbo.org/${DRONE_REPO}:${DRONE_BRANCH},mode=max,image-manifest=true,oci-mediatypes=true" - registry: gitea.scubbo.org - username: scubbo - password: - from_secret: gitea_password - repo: gitea.scubbo.org/${DRONE_REPO} - tags: - - ${DRONE_BRANCH} - - ${DRONE_COMMIT_SHA:0:10} - target: prod - platforms: - - linux/arm64 - - linux/amd64 - - - name: Update Helm Chart - image: alpine - environment: - GITEA_PASSWORD: - from_secret: gitea_password - GITEA_PAT: - from_secret: gitea_pat - commands: - # Cannot use `drone/git` plugin because: - # * it cannot check out to a different directory - # * if you try to clear the main directory and use it to checkout, Drone will just re-clone the original repo - # between steps - # ...God, I really need to transition off of Drone and onto a better CI tool... - - find . -not -path '.' | xargs rm -rf - - find . -not -path '.' - - apk add yq git - - git clone https://scubbo:${GITEA_PASSWORD}@gitea.scubbo.org/scubbo/helm-charts.git - - cd helm-charts - - cat charts/edh-elo/values.yaml - - yq -i '.image.tag = "${DRONE_COMMIT_SHA:0:10}"' charts/edh-elo/values.yaml - - git add -A - - git -c user.name="Imagebot" -c user.email="fake@scubbo.org" commit -m 'Update EDH ELO commit to "${DRONE_COMMIT_SHA:0:10}"' - - git remote add origin-with-credentials "https://scubbo:$GITEA_PAT@gitea.scubbo.org/scubbo/helm-charts.git" - - git push origin-with-credentials main:main - - - name: update-argo - image: curlimages/curl - environment: - ARGO_TOKEN: - from_secret: argo_token - commands: - - "curl -sS -X POST \"argo-cd-argocd-server.argo.svc.cluster.local/api/v1/applications/edh-elo/sync\" -H \"Authorization: Bearer ${ARGO_TOKEN}\" -H \"Content-Type: application/json\"" - - - name: purge-cache - image: curlimages/curl - environment: - CLOUDFLARE_TOKEN: - from_secret: cloudflare_token - commands: - - "curl -sS -X POST \"https://api.cloudflare.com/client/v4/zones/c86d55d225ed973d5da45239beac2f99/purge_cache\" -H \"Authorization: Bearer ${CLOUDFLARE_TOKEN}\" -H \"Content-Type:application/json\" -d '{\"files\":[\"https://edh-elo.scubbo.org/*\"]}'" diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index 0ae53a2..683ca03 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -51,4 +51,15 @@ jobs: run: | echo "Image pushed: gitea.scubbo.org/scubbo/edh-elo:${{ gitea.sha }}" - # TODO - update Helm chart with new image \ No newline at end of file + - name: Update Helm Chart + env: + GITEA_PASSWORD: ${{ env.GITEA_TOKEN }} + run: | + git clone https://scubbo:${GITEA_PASSWORD}@gitea.scubbo.org/scubbo/helm-charts.git + cd helm-charts + yq -i '.image.tag = "${{ gitea.sha }}"' charts/edh-elo/values.yaml + git add -A + git -c user.name="Imagebot" -c user.email="fake@scubbo.org" commit -m 'Update EDH ELO commit to "${{ gitea.sha }}"' + git push origin main:main + cd ... + rm -rf helm-charts diff --git a/app/routers/games.py b/app/routers/games.py index 5f1a74e..2115127 100644 --- a/app/routers/games.py +++ b/app/routers/games.py @@ -168,6 +168,9 @@ def game_create_html(request: Request, db=Depends(get_db)): @html_router.get("/list") def games_html(request: Request, db=Depends(get_db)): query_parameters = request.query_params + if not query_parameters: + # I.e. they navigated to just `/game/list`, meaning we should serve the default view - 10 latest games + query_parameters = {"sort_order": "desc", "limit": 10} # `**query_parameters` expands the object as named-params to the function - setting `limit` and `offset` appropriately games = list_games(db=db, **query_parameters) # TODO - a more "data-intensive application" implementation would fetch only the decks involved in the games for