mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-03-03 18:35:55 +00:00
Add workflow to push json changes to pocketbase
This commit is contained in:
13
.github/workflows/push-json-to-pocketbase.yml
generated
vendored
13
.github/workflows/push-json-to-pocketbase.yml
generated
vendored
@@ -78,23 +78,20 @@ jobs:
|
|||||||
const apiBase = /\/api$/i.test(raw) ? raw : raw + '/api';
|
const apiBase = /\/api$/i.test(raw) ? raw : raw + '/api';
|
||||||
const coll = process.env.POCKETBASE_COLLECTION;
|
const coll = process.env.POCKETBASE_COLLECTION;
|
||||||
const files = fs.readFileSync('changed_app_jsons.txt', 'utf8').trim().split(/\s+/).filter(Boolean);
|
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({
|
const authBody = JSON.stringify({
|
||||||
identity: process.env.POCKETBASE_ADMIN_EMAIL,
|
identity: process.env.POCKETBASE_ADMIN_EMAIL,
|
||||||
password: process.env.POCKETBASE_ADMIN_PASSWORD
|
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',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: authBody
|
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 token = JSON.parse(authRes.body).token;
|
||||||
const recordsUrl = apiBase + '/collections/' + encodeURIComponent(coll) + '/records';
|
const recordsUrl = apiBase + '/collections/' + encodeURIComponent(coll) + '/records';
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
|||||||
Reference in New Issue
Block a user