Skip to content

Commit 5e2a9b8

Browse files
committed
Implement automatic deploy using lftp.
1 parent e6af233 commit 5e2a9b8

File tree

5 files changed

+61
-11
lines changed

5 files changed

+61
-11
lines changed

Makefile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ cache-purge:
4949
-H "Content-Type:application/json" \
5050
--data '{"purge_everything":true}' # purge cubing.net cache
5151

52-
.PHONY: manual-deploy
53-
manual-deploy: build
54-
@echo "Opening Transmit for a manual deployment."
55-
open -a "Transmit"
56-
@echo "Press enter to purge the cache after the manual deployment is done."
57-
@read
58-
5952
.PHONY: deploy
60-
deploy: manual-deploy cache-purge
53+
deploy: deploy-dist cache-purge
54+
55+
.PHONY: deploy-dist
56+
deploy-dist: setup clean build
57+
./script/deploy.ts

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ script.type = "module";
2121
script.src = "http://speedsolving-twizzle.localhost:3344/misc/twizzle/js/twizzle-forum-link.js";
2222
document.body.appendChild(script)
2323
```
24+
25+
## Dependencies
26+
27+
- `lftp` (for deployment)

bun.lock

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@cubing/dev-config": "^0.3.6",
1717
"@types/bun": "^1.2.17",
1818
"barely-a-dev-server": "^0.8.1",
19-
"esbuild": "^0.25.5"
19+
"esbuild": "^0.25.5",
20+
"printable-shell-command": "^1.1.0"
2021
}
2122
}

script/deploy.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bun
2+
3+
import { homedir } from "node:os";
4+
import { join } from "node:path";
5+
import { file } from "bun";
6+
import { PrintableShellCommand } from "printable-shell-command";
7+
8+
// TODO: validation?
9+
interface Credentials {
10+
host: string;
11+
username: string;
12+
password: string;
13+
certFingerprint: string;
14+
}
15+
16+
const { host, username, password, certFingerprint } = (await file(
17+
join(
18+
homedir(),
19+
".ssh/ftps/speedsolving.com/speedsolving-forum.credentials.json",
20+
),
21+
).json()) as Credentials;
22+
23+
const commands = `set ftp:ssl-force true
24+
set ftp:ssl-protect-data true
25+
set ssl:verify-certificate/${certFingerprint} no
26+
mirror --verbose --reverse ./dist/www.speedsolving.com/misc/twizzle /misc/twizzle
27+
mirror --verbose --reverse ./dist/www.speedsolving.com/src/addons/Twizzle /src/addons/Twizzle
28+
bye
29+
EOF`;
30+
31+
const command = new PrintableShellCommand("lftp", [
32+
["--user", username],
33+
["--password", password],
34+
host,
35+
]).spawnBun({
36+
stdin: new Response(commands),
37+
stderr: "inherit",
38+
stdout: "inherit",
39+
});
40+
41+
await command.success;

0 commit comments

Comments
 (0)