minetest_x_bows/scripts/deploy.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-11-28 14:46:55 -06:00
/**
* Deploy code to CDB
2023-02-15 13:03:24 -06:00
* Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com>
2022-11-28 14:46:55 -06:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to juraj.vajda@gmail.com
*/
2022-11-02 23:04:43 -05:00
import fetch from 'node-fetch'
import yargs from 'yargs/yargs'
import {hideBin} from 'yargs/helpers'
const argv = yargs(hideBin(process.argv)).argv
try {
const body = {
method: 'git',
title: argv.title,
ref: 'master'
}
const response = await fetch('https://content.minetest.net/api/packages/SaKeL/x_bows/releases/new/', {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${argv.token}`
}
})
const data = await response.json()
2022-11-02 23:19:09 -05:00
console.log(data)
2022-11-02 23:22:03 -05:00
if (!data.success) {
2022-11-02 23:04:43 -05:00
process.exit(1)
}
} catch (error) {
console.log(error)
process.exit(1)
}