mirrorer

:)
git clone https://git.sr.ht/~ashymad/mirrorer
Log | Files | Refs | LICENSE

commit e0713460a7b5d457e2dc48e844571263c4c4a555
parent 035db10eb1882102fe20036c8f4ae951ea86dcff
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date:   Sun, 14 Jun 2026 22:57:08 +0200

Should be working now

Diffstat:
M.build.yml | 2++
Mworker/src/index.ts | 49++++++++++++++++++++++++++++++++++++-------------
2 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/.build.yml b/.build.yml @@ -1,5 +1,7 @@ image: alpine/edge oauth: pages.sr.ht/PAGES:RW +sources: + - https://git.sr.ht/~ashymad/mirrorer packages: - hut - git diff --git a/worker/src/index.ts b/worker/src/index.ts @@ -19,22 +19,45 @@ export default { async fetch(req) { return new Response(`I am just a humble cloudflare worker :)`); }, - - async scheduled(event, env, ctx): Promise<void> { - let resp = await fetch('https://builds.sr.ht/query', { - method: 'POST', + async scheduled(event, env, ctx) { + let yml_req = await fetch("https://git.sr.ht/query", { + method: "POST", headers: { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${env.SRHTTOKEN}` + "Content-Type": "application/json", + "Authorization": `Bearer ${env.SRHTTOKEN}` }, body: JSON.stringify({ - 'query': '{ version { major, minor, patch } }' - }) + "query": `{ + repositories(filter: {count: 1, search: "~ashymad/mirrorer"}) { + results { + path(path: ".build.yml") { + object { + ... on TextBlob { + text + } + } + } + } + } + }`}) }); - - resp.json().then(function (obj) { - console.log(`Response at ${event.cron}: ${JSON.stringify(obj, null, 2)}`); + let yml = (await yml_req.json()).data.repositories.results[0].path.object.text; + let job_req = await fetch("https://builds.sr.ht/query", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${env.SRHTTOKEN}` + }, + body: JSON.stringify({ + "query": `mutation ($yml: String!) { + submit(manifest: $yml) { + id + } + }`, + "variables": { + "yml": yml + }}) }); - - }, + console.log(`Build submitted at ${event.cron}: ${JSON.stringify(await job_req.json())}`); + } } satisfies ExportedHandler<Env>;