Skip to content

Commit 1db1b17

Browse files
committed
ci: 部署
1 parent c869c76 commit 1db1b17

File tree

4 files changed

+877
-0
lines changed

4 files changed

+877
-0
lines changed

.github/workflows /static.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Single deploy job since we're just deploying
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Setup Pages
35+
uses: actions/configure-pages@v5
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
# Upload entire repository
40+
path: './dist'
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v4

dist/index.html

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head><link rel="modulepreload" href="/mini-note-dd0ee225576671bf.js" crossorigin=anonymous integrity="sha384-KsnTD8RMZuTYNhdmh0d5MAS8OGc55h5HHSbzqCstI/LD0W37NJ99GIMog3YZZAb6"><link rel="preload" href="/mini-note-dd0ee225576671bf_bg.wasm" crossorigin=anonymous integrity="sha384-gqTkPWMAsYcUvPapd2DLq91BmhOb5vnHmIi32ruM998yghWImzbmYdt/qIlzXBS3" as="fetch" type="application/wasm"></head>
4+
<body>
5+
<script type="module" nonce="VEXomg5aQ5Rwu9MRIMLWJw==">
6+
import init, * as bindings from '/mini-note-dd0ee225576671bf.js';
7+
const wasm = await init({ module_or_path: '/mini-note-dd0ee225576671bf_bg.wasm' });
8+
9+
10+
window.wasmBindings = bindings;
11+
12+
13+
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));
14+
15+
</script><script>"use strict";
16+
17+
(function () {
18+
19+
const address = '{{__TRUNK_ADDRESS__}}';
20+
const base = '{{__TRUNK_WS_BASE__}}';
21+
let protocol = '';
22+
protocol =
23+
protocol
24+
? protocol
25+
: window.location.protocol === 'https:'
26+
? 'wss'
27+
: 'ws';
28+
const url = protocol + '://' + address + base + '.well-known/trunk/ws';
29+
30+
class Overlay {
31+
constructor() {
32+
// create an overlay
33+
this._overlay = document.createElement("div");
34+
const style = this._overlay.style;
35+
style.height = "100vh";
36+
style.width = "100vw";
37+
style.position = "fixed";
38+
style.top = "0";
39+
style.left = "0";
40+
style.backgroundColor = "rgba(222, 222, 222, 0.5)";
41+
style.fontFamily = "sans-serif";
42+
// not sure that's the right approach
43+
style.zIndex = "1000000";
44+
style.backdropFilter = "blur(1rem)";
45+
46+
const container = document.createElement("div");
47+
// center it
48+
container.style.position = "absolute";
49+
container.style.top = "30%";
50+
container.style.left = "15%";
51+
container.style.maxWidth = "85%";
52+
53+
this._title = document.createElement("div");
54+
this._title.innerText = "Build failure";
55+
this._title.style.paddingBottom = "2rem";
56+
this._title.style.fontSize = "2.5rem";
57+
58+
this._message = document.createElement("div");
59+
this._message.style.whiteSpace = "pre-wrap";
60+
61+
const icon= document.createElement("div");
62+
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="#dc3545" viewBox="0 0 16 16"><path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/></svg>';
63+
this._title.prepend(icon);
64+
65+
container.append(this._title, this._message);
66+
this._overlay.append(container);
67+
68+
this._inject();
69+
window.setInterval(() => {
70+
this._inject();
71+
}, 250);
72+
}
73+
74+
set reason(reason) {
75+
this._message.textContent = reason;
76+
}
77+
78+
_inject() {
79+
if (!this._overlay.isConnected) {
80+
// prepend it
81+
document.body?.prepend(this._overlay);
82+
}
83+
}
84+
85+
}
86+
87+
class Client {
88+
constructor(url) {
89+
this.url = url;
90+
this.poll_interval = 5000;
91+
this._overlay = null;
92+
}
93+
94+
start() {
95+
const ws = new WebSocket(this.url);
96+
ws.onmessage = (ev) => {
97+
const msg = JSON.parse(ev.data);
98+
switch (msg.type) {
99+
case "reload":
100+
this.reload();
101+
break;
102+
case "buildFailure":
103+
this.buildFailure(msg.data)
104+
break;
105+
}
106+
};
107+
ws.onclose = this.onclose;
108+
}
109+
110+
onclose() {
111+
window.setTimeout(
112+
() => {
113+
// when we successfully reconnect, we'll force a
114+
// reload (since we presumably lost connection to
115+
// trunk due to it being killed, so it will have
116+
// rebuilt on restart)
117+
const ws = new WebSocket(this.url);
118+
ws.onopen = () => window.location.reload();
119+
ws.onclose = this.onclose;
120+
},
121+
this.poll_interval);
122+
}
123+
124+
reload() {
125+
window.location.reload();
126+
}
127+
128+
buildFailure({reason}) {
129+
// also log the console
130+
console.error("Build failed:", reason);
131+
132+
console.debug("Overlay", this._overlay);
133+
134+
if (!this._overlay) {
135+
this._overlay = new Overlay();
136+
}
137+
this._overlay.reason = reason;
138+
}
139+
}
140+
141+
new Client(url).start();
142+
143+
})()
144+
</script></body>
145+
</html>

0 commit comments

Comments
 (0)