2024-08-22 16:26:38 +00:00
|
|
|
import core from "@actions/core";
|
|
|
|
|
|
|
|
import gitea from "gitea-api";
|
|
|
|
|
|
|
|
async function run() {
|
|
|
|
try {
|
|
|
|
const host = core.getInput("host");
|
|
|
|
const token = core.getInput("token");
|
|
|
|
const repository = core.getInput("repository");
|
|
|
|
|
|
|
|
const [owner, repo] = repository.split("/");
|
|
|
|
|
2024-08-22 17:03:09 +00:00
|
|
|
const client = new gitea.GiteaApi({
|
2024-08-22 16:26:38 +00:00
|
|
|
BASE: `https://${host}/api/v1`,
|
|
|
|
WITH_CREDENTIALS: true,
|
|
|
|
TOKEN: token,
|
|
|
|
});
|
|
|
|
|
2024-08-22 17:03:09 +00:00
|
|
|
let release = await client.repository.repoGetReleaseByTag({
|
|
|
|
owner: owner,
|
|
|
|
repo: repo,
|
|
|
|
tag: body.tag_name,
|
|
|
|
});
|
|
|
|
const release_id = release.id;
|
|
|
|
let target_commitish = release.target_commitish;
|
|
|
|
if (
|
|
|
|
body.target_commitish &&
|
|
|
|
body.target_commitish !== release.target_commitish
|
|
|
|
) {
|
|
|
|
console.log(
|
|
|
|
`Updating commit from "${release.target_commitish}" to "${body.target_commitish}"`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
target_commitish = body.target_commitish;
|
|
|
|
release = client.repository.repoEditRelease({
|
|
|
|
owner: owner,
|
|
|
|
repo: repo,
|
|
|
|
id: release_id,
|
|
|
|
body: {
|
|
|
|
body: body.body || release.body,
|
|
|
|
draft: body.draft !== undefined ? body.draft : release.draft,
|
|
|
|
name: body.name || release.name,
|
|
|
|
prerelease:
|
|
|
|
body.prerelease !== undefined ? body.prerelease : release.prerelease,
|
|
|
|
tag_name: body.tag_name || release.tag_name,
|
|
|
|
target_commitish: target_commitish,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-08-22 16:26:38 +00:00
|
|
|
console.log(`TEST ${host} ${token} ${repository} ${owner} ${repo}`);
|
|
|
|
// console.log(`🎉 Release ready at ${response.html_url}`);
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|