Set up deploy pipeline (hopefully).

This commit is contained in:
Condorra 2023-02-17 02:04:46 +11:00
parent 42846cf2dd
commit be58d5ed9b
8 changed files with 86 additions and 6 deletions

6
.ci/build Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash -e
set -Eeuo pipefail
cd siterepo
./build.sh
cp ./assets/* ../sitegen/

17
.ci/deploy Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
set -Eeu
DEPLOY_HOST=172.19.11.5
mkdir -p ~/.ssh
cat >>~/.ssh/known_hosts <<END
172.19.11.5 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCm71djj4D0EX/rW9p0d4t/gIoUMK8kMJEs71KadFUu3Ij2BHqbS3U8G3sjm6qm7nU7c0QD1WNyzLbCp23qroobS2/TOjvewZMe5Gs4iGBmE5VLJHY/hD0AKHermcrv1z7KbLnLaCgqQdGdzqcPs07Z9BdbHBDHq57+VJsIQ9BCt67GevppPyV6sIQX9h6aoLo4179vwQ9tC7fPcp8GzO7PTcixMhWGF0A12YcMxA3OR5q3GoeQxGZ3wRXg7avNJhHuAI3tWIA5VUcn/DTuRC16ndSVuyxous/L+jxNuk7wDIDXRPuOin7edoJ7s4ZXxV7EWPKANZzzmStQzeLX7ew9K6uF1BNmzZArK03ts8H/h6Q/O8KB1/oCnAtpoCMHfDM2AiF9SOAa9S6yBmYFAGXgLV+BdnbZnIpOIE6zyPv3k/c9zzFW7ZoQ9V7VWomCX7FxL6uwoaBoVAeCSVkfrxFoXnzIyrcaGXBUlWftTKpB0jqCdJ/Eifquj9ImIE5CcNk=
172.19.11.5 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC5PjzIMikn+AJWyvge7DqFsdMarG9CVDov9ITbDwNwucoeEUlNoA3hypyrBeatyRL3Y+jWtPV6uwzlRTKye/BY=
172.19.11.5 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEi7lEzVWCLed6VZgnIpfXF7+bugZ6uZwH2hOkIgtfAv
END
chmod 0600 ~/.ssh/known_hosts
echo "$DEPLOY_KEY" >deploy-key
chmod 0600 ./deploy-key
rsync -av sitegen/ blast@$DEPLOY_HOST:/mnt/static/main/

2
.ci/fly-set-pipeline Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec fly -t bm set-pipeline -c .concourse.yml -p blastmud-site

47
.concourse.yml Normal file
View File

@ -0,0 +1,47 @@
jobs:
- name: build-site
public: true
build_log_retention:
days: 365
builds: 50
plan:
- get: siterepo
trigger: true
- task: build
config:
platform: linux
image_resource:
type: registry-image
source:
repository: node
inputs:
- name: siterepo
caches:
- path: node_modules
- path: dist
outputs:
- name: sitegen
run:
path: siterepo/.ci/build
- task: deploy
config:
platform: linux
image_resource:
type: registry-image
source:
repository: blasthavers/deploy-base
inputs:
- name: sitegen
- name: siterepo
params:
DEPLOY_KEY: ((deploy_key))
run:
path: siterepo/.ci/deploy
resources:
- name: siterepo
type: git
check_every: never
webhook_token: ((webhook_token))
source:
uri: https://git.blastmud.org/blasthavers/blastmud-site.git
branch: main

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
assets/main.js assets/main.js
dist dist
node_modules node_modules
assets/xterm.css assets/xterm.css

View File

@ -23,6 +23,11 @@
<h1 style="text-align: center">Play Blastmud</h1> <h1 style="text-align: center">Play Blastmud</h1>
<div id="console" style="min-height: 40pt; flex: 1">&nbsp;</div> <div id="console" style="min-height: 40pt; flex: 1">&nbsp;</div>
</div> </div>
<div id="notyet" style="position: absolute; top: 0; left: 0; background: rgba(80,80,80,0.8); width: 100%; height: 100%">
<div style="display: block; padding: 10px; background: white; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10%; border-radius: 10px;">
Sorry, this game is not yet available for play.
</div>
</div>
<div id="over18" style="position: absolute; top: 0; left: 0; background: rgba(80,80,80,0.8); width: 100%; height: 100%"> <div id="over18" style="position: absolute; top: 0; left: 0; background: rgba(80,80,80,0.8); width: 100%; height: 100%">
<div style="display: block; padding: 10px; background: white; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10%; border-radius: 10px;"> <div style="display: block; padding: 10px; background: white; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10%; border-radius: 10px;">
<h1>You must be 18+ to play Blastmud</h1> <h1>You must be 18+ to play Blastmud</h1>

View File

@ -23,10 +23,16 @@ async function readForever() {
} }
readForever(); readForever();
const params: {[key:string]: string} =
location.search.substr(1).split('&')
.reduce((o, s) => { const [k, v] = s.split('='); o[k] = v; return o;},
{} as {[key:string]: string});
function connectTerm() { function connectTerm() {
lineHandler = () => {}; lineHandler = () => {};
term.writeln("\x1b[0mConnecting to server..."); term.writeln("\x1b[0mConnecting to server...");
const wsurl = document.location.href.replace(/^https:\/\/(.*)\/game(.html)?(\?.*)?(\#.*)?/, 'wss:\/\/$1/wsgame'); const wsurl = (document.localStorage['allow_wsurl'] !== true || params.wsurl === undefined) ?
"wss://ws.blastmud.org/wsgame" : params.wsurl;
let webSocket = new WebSocket(wsurl); let webSocket = new WebSocket(wsurl);
webSocket.addEventListener('open', (event) => { webSocket.addEventListener('open', (event) => {
if (sendLessExplicit) if (sendLessExplicit)
@ -58,13 +64,10 @@ function over18() {
} }
if ('serviceWorker' in navigator) navigator.serviceWorker.register('service-worker.js'); if ('serviceWorker' in navigator) navigator.serviceWorker.register('service-worker.js');
const params: {[key:string]: string} =
location.search.substr(1).split('&')
.reduce((o, s) => { const [k, v] = s.split('='); o[k] = v; return o;},
{} as {[key:string]: string});
if (params["source"] && params["source"] === "android") { if (params["source"] && params["source"] === "android") {
isScreened = true; isScreened = true;
sendLessExplicit = true; sendLessExplicit = true;
document.getElementById("notyet").style.display = 'none';
} }
if (isScreened || window.localStorage['over18']) { if (isScreened || window.localStorage['over18']) {