Data Request API helper #10
1 changed files with 22 additions and 5 deletions
|
|
@ -1,11 +1,28 @@
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
const {
|
const {
|
||||||
TAG_NAME,
|
TAG_NAME,
|
||||||
FORGEJO_API_URL,
|
FORGEJO_API_URL: API_URL,
|
||||||
FORGEJO_REPOSITORY,
|
FORGEJO_REPOSITORY: REPO,
|
||||||
FORGEJO_REPOSITORY_OWNER,
|
FORGEJO_TOKEN: TOKEN,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const requestURL = `${API_URL}/repos/${REPO}/tags/${TAG_NAME}`;
|
||||||
|
|
||||||
console.log(process.env)
|
const response = await axios.get(
|
||||||
|
requestURL,
|
||||||
|
{
|
||||||
|
headers: { Authorization: `token ${TOKEN}` },
|
||||||
|
validateStatus: () => true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// We actually *want* an error when the tag exists, instead of when
|
||||||
|
// it doesn't
|
||||||
|
if (response.status === 200) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
main();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue