sim0n00ps 0dcd38e0ab
Some checks failed
Publish Docker image / Push docker image to registry (push) Failing after 5s
Publish release zip / build (push) Failing after 3s
More tweaks to actions
2025-05-04 17:26:18 +01:00

36 lines
944 B
JavaScript

const fs = require('fs');
const path = require('path');
const core = require('@actions/core');
const fetch = require('node-fetch');
(async () => {
try {
const token = process.env.GITEA_TOKEN;
const uploadUrl = core.getInput('upload_url');
const assetPath = core.getInput('asset_path');
const assetName = core.getInput('asset_name');
const contentType = core.getInput('asset_content_type');
const fileData = fs.readFileSync(assetPath);
const url = `${uploadUrl}?name=${encodeURIComponent(assetName)}`;
const res = await fetch(url, {
method: 'POST',
headers: {
Authorization: `token ${token}`,
'Content-Type': contentType,
},
body: fileData
});
if (!res.ok) {
throw new Error(`Failed to upload asset: ${res.status} ${await res.text()}`);
}
core.info(`Asset uploaded: ${assetName}`);
} catch (err) {
core.setFailed(err.message);
}
})();