mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 06:00:45 -06:00
Compare commits
No commits in common. "dd5ee96b87cffa52da447f29fa4f63b16630f31e" and "290280f71478e89efeddae0e3f9b4c2ef59e8c29" have entirely different histories.
dd5ee96b87
...
290280f714
4 changed files with 49 additions and 145 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
elizabeth-and-daylin.com {
|
||||
reverse_proxy http://localhost:4321
|
||||
}
|
||||
|
@ -7,6 +6,10 @@ elizabeth.dayl.in, www.elizabeth-and-daylin.com {
|
|||
redir https://elizabeth-and-daylin.com{uri} permanent
|
||||
}
|
||||
|
||||
attic.dayl.in {
|
||||
reverse_proxy http://localhost:5656
|
||||
}
|
||||
|
||||
git.dayl.in {
|
||||
reverse_proxy http://localhost:3000
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Attic Binary Cache</title>
|
||||
<style>
|
||||
.cursor {
|
||||
display: inline-block;
|
||||
background-color: black;
|
||||
animation-name: cursor;
|
||||
animation-duration: 0.8s;
|
||||
animation-iteration-count: infinite;
|
||||
}
|
||||
@keyframes cursor {
|
||||
0% {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
20% {
|
||||
background-color: #555;
|
||||
}
|
||||
50% {
|
||||
background-color: #555;
|
||||
}
|
||||
60% {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
100% {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
}
|
||||
/* https://stackoverflow.com/a/13356401 */
|
||||
body {
|
||||
background-color: #1e1e2e;
|
||||
}
|
||||
pre {
|
||||
color: #f5e0dc;
|
||||
}
|
||||
#box {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="box">
|
||||
<pre>
|
||||
┏━━━━━━━━━━━━━━━━┑
|
||||
┃┏━━━ @ ━━━ @ ━━┓┃
|
||||
┃┃ ┃┃
|
||||
┃┃$ attic push <div class="cursor"> </div>┃┃
|
||||
┃┃ ┃┃
|
||||
┃┗━━━ ╰─────╯ ━━┛┃
|
||||
┗━━━━━━━━━━━━━━━━┛
|
||||
╲ ############### ╲
|
||||
╲ ############### ╲
|
||||
╲ ############### ╲
|
||||
━━━━━━━━━━━━━━━━━━
|
||||
</pre>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,10 +1,6 @@
|
|||
{ pkgs, enabled, ... }:
|
||||
let
|
||||
atticPort = "5656";
|
||||
static = pkgs.runCommandLocal "static-files" { } ''
|
||||
mkdir $out
|
||||
cp ${./caddy/index.html} $out/index.html
|
||||
'';
|
||||
in
|
||||
{
|
||||
|
||||
|
@ -19,22 +15,12 @@ in
|
|||
settings.PasswordAuthentication = false;
|
||||
};
|
||||
|
||||
services.comin = enabled // {
|
||||
remotes = [
|
||||
{
|
||||
name = "origin";
|
||||
url = "https://github.com/daylinmorgan/oizys.git";
|
||||
branches.main.name = "main";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
security.polkit = enabled; # attic was looking for this...
|
||||
environment.systemPackages = [ pkgs.attic-client ];
|
||||
|
||||
# allow docker to forward the request to the host running attic
|
||||
# https://discourse.nixos.org/t/docker-container-not-resolving-to-host/30259/6
|
||||
# networking.firewall.extraCommands = "iptables -A INPUT -p tcp --destination-port ${atticPort} -s 172.16.0.0/12 -j ACCEPT";
|
||||
networking.firewall.extraCommands = "iptables -A INPUT -p tcp --destination-port ${atticPort} -s 172.16.0.0/12 -j ACCEPT";
|
||||
services.atticd = enabled // {
|
||||
|
||||
# Replace with absolute path to your credentials file
|
||||
|
@ -70,19 +56,17 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
services.comin = enabled // {
|
||||
remotes = [
|
||||
{
|
||||
name = "origin";
|
||||
url = "https://github.com/daylinmorgan/oizys.git";
|
||||
branches.main.name = "main";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
services.caddy = enabled // {
|
||||
extraConfig = builtins.readFile ./caddy/Caddyfile;
|
||||
virtualHosts."attic.dayl.in".extraConfig = ''
|
||||
redir /oizys /
|
||||
|
||||
handle / {
|
||||
root * ${static}
|
||||
file_server
|
||||
}
|
||||
|
||||
handle /* {
|
||||
reverse_proxy http://localhost:5656
|
||||
}
|
||||
'';
|
||||
extraConfig = builtins.readFile ./Caddyfile;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles, times]
|
||||
import std/[httpclient,logging, os, strformat, strutils, json, tables, tempfiles]
|
||||
import jsony, hwylterm, hwylterm/logging, zippy/ziparchives
|
||||
import ./[exec, context]
|
||||
|
||||
|
@ -12,33 +12,6 @@ template withTmpDir(body: untyped): untyped =
|
|||
body
|
||||
removeDir tmpDir
|
||||
|
||||
type
|
||||
GhArtifact = object
|
||||
id: int
|
||||
name: string
|
||||
url: string
|
||||
archive_download_url*: string
|
||||
|
||||
GhWorkflowRun = object
|
||||
id*: int
|
||||
node_id: string
|
||||
run_number: int
|
||||
event: string
|
||||
status: string
|
||||
conclusion: string
|
||||
html_url: string
|
||||
workflow_id: int
|
||||
created_at*: string # use datetime?
|
||||
updated_at: string # use datetime?
|
||||
|
||||
ListGhArtifactResponse = object
|
||||
total_count: int
|
||||
artifacts: seq[GhArtifact]
|
||||
|
||||
ListGhWorkflowResponse = object
|
||||
total_count: int
|
||||
workflow_runs: seq[GhWorkflowRun]
|
||||
|
||||
var ghToken = getEnv "GITHUB_TOKEN"
|
||||
|
||||
proc checkToken() {.inline.} =
|
||||
|
@ -79,35 +52,47 @@ proc postGhApi(url: string, body: JsonNode) =
|
|||
except:
|
||||
errorQuit "failed to get response code"
|
||||
|
||||
proc getInProgressRun(workflow: string, timeout: int = 5000): (GhWorkflowRun, bool) =
|
||||
let
|
||||
start = now()
|
||||
timeoutDuration = initDuration(milliseconds = timeout)
|
||||
|
||||
withSpinner fmt"waiting for {workflow} workflow to start":
|
||||
while (now() - start) < timeoutDuration:
|
||||
let response = getGhApi(fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/workflows/{workflow}/runs")
|
||||
let runs = fromJson(response.body, ListGhWorkflowResponse).workflow_runs
|
||||
if runs[0].status == "in_progress":
|
||||
spinner.stop() # cleanup
|
||||
return (runs[0], true)
|
||||
sleep 500
|
||||
|
||||
warn "timeout reached waiting for workflow to start"
|
||||
|
||||
proc createDispatch*(workflowFileName: string, `ref`: string) =
|
||||
## https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
|
||||
let workflow =
|
||||
var workflow =
|
||||
if workflowFileName.endsWith(".yml") or workflowFileName.endsWith(".yaml"): workflowFileName
|
||||
else: workflowFileName & ".yml"
|
||||
let body = %*{"ref": `ref`}
|
||||
info fmt"creating dispatch event for {workflow}"
|
||||
postGhApi(
|
||||
fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/workflows/{workflow}/dispatches",
|
||||
body
|
||||
%*{
|
||||
"ref": `ref`,
|
||||
}
|
||||
)
|
||||
let (run, ok) = getInProgressRun(workflow)
|
||||
if ok: info "view workflow run at: " & run.html_url
|
||||
|
||||
type
|
||||
GhArtifact = object
|
||||
id: int
|
||||
name: string
|
||||
url: string
|
||||
archive_download_url*: string
|
||||
|
||||
GhWorkflowRun = object
|
||||
id*: int
|
||||
node_id: string
|
||||
run_number: int
|
||||
event: string
|
||||
status: string
|
||||
conclusion: string
|
||||
html_url: string
|
||||
workflow_id: int
|
||||
created_at*: string # use datetime?
|
||||
updated_at: string # use datetime?
|
||||
|
||||
ListGhArtifactResponse = object
|
||||
total_count: int
|
||||
artifacts: seq[GhArtifact]
|
||||
|
||||
ListGhWorkflowResponse = object
|
||||
total_count: int
|
||||
workflow_runs: seq[GhWorkflowRun]
|
||||
|
||||
|
||||
proc listUpdateRuns(): seq[GhWorkflowRun] =
|
||||
## get update.yml runs
|
||||
|
|
Loading…
Reference in a new issue