Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4affa135cd | ||
|
|
f2a9e1762f |
No files matched your search
@@ -23,8 +23,12 @@ jobs:
|
||||
- name: Type check
|
||||
run: npm run check
|
||||
|
||||
# The API is its own origin when deployed. Overridable with the
|
||||
# TERN_API_URL repository variable.
|
||||
- name: Build
|
||||
run: npm run build
|
||||
env:
|
||||
VITE_TERN_API: ${{ vars.TERN_API_URL || 'https://tern-api.mtps.pl' }}
|
||||
|
||||
- name: Create release archive
|
||||
run: |
|
||||
@@ -45,39 +49,14 @@ jobs:
|
||||
tern-web-*.tgz
|
||||
tern-web-*.tgz.sha256
|
||||
|
||||
# Deploys the release to tern.mtps.pl (kara, deploy/compose). It lives
|
||||
# here rather than in tern-server because tags are pushed server-first and
|
||||
# the single runner works through them in order, so by the time this runs
|
||||
# both the server image and this webapp release exist. A deploy job in
|
||||
# tern-server would have to wait for this repo's release while holding
|
||||
# the only runner.
|
||||
# Deploys the release just published to tern.mtps.pl (deploy/static on
|
||||
# the swarm; see deploy/static.yml).
|
||||
deploy:
|
||||
needs: release
|
||||
runs-on: rocky-10
|
||||
steps:
|
||||
# The deployment definition is versioned with the server it deploys.
|
||||
- name: Check out deployment definition
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: mtps/tern-server
|
||||
ref: ${{ gitea.ref_name }}
|
||||
|
||||
- name: Check the server image exists
|
||||
env:
|
||||
IMAGE: git.app.ygg/mtps/tern-server
|
||||
TAG: ${{ gitea.ref_name }}
|
||||
run: |
|
||||
# Fails fast with a clear message if the server release didn't
|
||||
# publish this version (failed, or still running on another
|
||||
# runner), instead of a deploy that can't pull its image.
|
||||
VERSION="${TAG#v}"
|
||||
for i in $(seq 1 20); do
|
||||
docker manifest inspect "$IMAGE:$VERSION" >/dev/null 2>&1 && exit 0
|
||||
echo "waiting for $IMAGE:$VERSION ($i/20)"
|
||||
sleep 30
|
||||
done
|
||||
echo "::error::$IMAGE:$VERSION not found in the registry — did the tern-server release succeed?"
|
||||
exit 1
|
||||
|
||||
- name: Derive version
|
||||
id: version
|
||||
@@ -88,10 +67,9 @@ jobs:
|
||||
- name: Deploy
|
||||
uses: https://git.app.ygg/ygg/actions/deploy@v2
|
||||
with:
|
||||
type: compose
|
||||
dist-path: deploy/tern.yml
|
||||
type: static
|
||||
dist-path: deploy/static.yml
|
||||
extra-vars: |
|
||||
version=${{ steps.version.outputs.version }}
|
||||
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# tern-web's deployment: a Swarm stack of ygg/static-server serving this
|
||||
# version's release asset, on tern.mtps.pl (deploy/static in the ygg
|
||||
# management repo). Run by this repo's release workflow through
|
||||
# ygg/actions/deploy; `version` arrives as an extra var (the tag without
|
||||
# its v) and is templated in by Ansible.
|
||||
#
|
||||
# The webapp talks to tern-server at tern-api.mtps.pl, baked in at build
|
||||
# time (VITE_TERN_API in the release workflow).
|
||||
|
||||
static_stack_name: tern-web
|
||||
|
||||
domain: tern.mtps.pl
|
||||
cert: mtps.pl
|
||||
|
||||
static_service:
|
||||
name: static
|
||||
image: git.app.ygg/ygg/static-server:latest
|
||||
environment:
|
||||
GITEA_REPOSITORY_URL: https://git.app.ygg/mtps/tern-web
|
||||
GITEA_RELEASE: "v{{ version }}"
|
||||
GITEA_ASSET_NAME: "tern-web-{{ version }}.tgz"
|
||||
SSL_CERT_FILE: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
|
||||
volumes:
|
||||
- /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:ro
|
||||
ports:
|
||||
- target: 8080
|
||||
published: 11902
|
||||
protocol: tcp
|
||||
mode: ingress
|
||||
replicas: 2
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "tern-web",
|
||||
"version": "0.8.2",
|
||||
"version": "0.8.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "tern-web",
|
||||
"version": "0.8.2",
|
||||
"version": "0.8.3",
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||
"@tsconfig/svelte": "^5.0.4",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "tern-web",
|
||||
"private": true,
|
||||
"version": "0.8.2",
|
||||
"version": "0.8.3",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
+8
-1
@@ -4,6 +4,13 @@
|
||||
|
||||
const SESSION_KEY = 'tern-session-token';
|
||||
|
||||
/**
|
||||
* Where tern-server lives, fixed at build time (VITE_TERN_API). Deployed,
|
||||
* the webapp and the API are separate origins; in development it's empty
|
||||
* and Vite's proxy forwards /api on the same origin.
|
||||
*/
|
||||
export const API_ORIGIN = (import.meta.env.VITE_TERN_API ?? '').replace(/\/+$/, '');
|
||||
|
||||
export function getSessionToken(): string | null {
|
||||
return localStorage.getItem(SESSION_KEY);
|
||||
}
|
||||
@@ -18,7 +25,7 @@ export function clearSessionToken(): void {
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const token = getSessionToken();
|
||||
const res = await fetch(`/api${path}`, {
|
||||
const res = await fetch(`${API_ORIGIN}/api${path}`, {
|
||||
...init,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// polling the same event log while it isn't. Both carry the same cursor,
|
||||
// so switching between them neither drops nor repeats a change.
|
||||
|
||||
import { getSessionToken, pollEvents, type LiveEvent } from './api';
|
||||
import { API_ORIGIN, getSessionToken, pollEvents, type LiveEvent } from './api';
|
||||
|
||||
export type LiveStatus = 'connecting' | 'live' | 'polling';
|
||||
|
||||
@@ -55,7 +55,7 @@ export function startLive(handlers: LiveHandlers): () => void {
|
||||
return;
|
||||
}
|
||||
handlers.onStatus(cursor === null ? 'connecting' : 'polling');
|
||||
const url = new URL('/api/ws', location.href);
|
||||
const url = new URL('/api/ws', API_ORIGIN || location.href);
|
||||
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const ws = new WebSocket(url);
|
||||
socket = ws;
|
||||
|
||||
Vendored
+5
@@ -1,2 +1,7 @@
|
||||
/// <reference types="svelte" />
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
/** tern-server's origin, e.g. https://tern-api.mtps.pl. Empty: same origin. */
|
||||
readonly VITE_TERN_API?: string;
|
||||
}
|
||||
Reference in new issue
Block a user