From 7d5900de189010f642f3d1519af23e1d4599c443 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Mon, 2 Mar 2026 15:26:29 +0100 Subject: [PATCH] Add workflow to push json changes to pocketbase --- .github/workflows/push-json-to-pocketbase.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/push-json-to-pocketbase.yml b/.github/workflows/push-json-to-pocketbase.yml index 502ca5739..33afbe954 100644 --- a/.github/workflows/push-json-to-pocketbase.yml +++ b/.github/workflows/push-json-to-pocketbase.yml @@ -78,23 +78,20 @@ jobs: const apiBase = /\/api$/i.test(raw) ? raw : raw + '/api'; const coll = process.env.POCKETBASE_COLLECTION; const files = fs.readFileSync('changed_app_jsons.txt', 'utf8').trim().split(/\s+/).filter(Boolean); + const authUrl = apiBase + '/collections/users/auth-with-password'; + console.log('Auth URL: ' + authUrl); const authBody = JSON.stringify({ identity: process.env.POCKETBASE_ADMIN_EMAIL, password: process.env.POCKETBASE_ADMIN_PASSWORD }); - let authRes = await request(apiBase + '/admins/auth-with-password', { + const authRes = await request(authUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: authBody }); - if (!authRes.ok && authRes.statusCode === 404) { - authRes = await request(raw + '/admins/auth-with-password', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: authBody - }); + if (!authRes.ok) { + throw new Error('Auth failed. Tried: ' + authUrl + ' - Verify POST to that URL with body {"identity":"...","password":"..."} works. Response: ' + authRes.body); } - if (!authRes.ok) throw new Error('Auth failed (check POCKETBASE_URL): ' + authRes.body); const token = JSON.parse(authRes.body).token; const recordsUrl = apiBase + '/collections/' + encodeURIComponent(coll) + '/records'; for (const file of files) {