Add workflow to push json changes to pocketbase

This commit is contained in:
Michel Roegl-Brunner
2026-03-02 14:37:50 +01:00
parent 9849ce79a7
commit 00047c95b8

View File

@@ -74,7 +74,8 @@ jobs:
req.end();
});
}
const base = process.env.POCKETBASE_URL.replace(/\/$/, '') + '/api';
const raw = process.env.POCKETBASE_URL.replace(/\/$/, '');
const base = /\/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 authRes = await request(base + '/admins/auth-with-password', {
@@ -85,7 +86,7 @@ jobs:
password: process.env.POCKETBASE_ADMIN_PASSWORD
})
});
if (!authRes.ok) throw new Error('Auth failed: ' + authRes.body);
if (!authRes.ok) throw new Error('Auth failed (check POCKETBASE_URL; use base URL without /api): ' + authRes.body);
const token = JSON.parse(authRes.body).token;
const recordsPath = '/api/collections/' + encodeURIComponent(coll) + '/records';
const recordsUrl = base.replace(/\/api$/, '') + recordsPath;