WIP: Build & Release

This commit is contained in:
Michał Zieliński
2025-02-12 15:39:32 +01:00
parent 8e4312f0dd
commit b5c5bf08d2
5 changed files with 89 additions and 58 deletions

View File

@@ -0,0 +1,26 @@
module.exports = async ({ github, context, core, jobId, name }) => {
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: jobId,
});
if (artifacts.data.total_count === 0) {
core.setFailed("No artifacts found for jobID: " + jobId);
return false;
}
const artifact = artifacts.data.artifacts.find(
(artifact) => artifact.name === name
);
if (!artifact) {
core.setFailed(`${name} not found in artifacts`);
return false;
}
const response = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: "zip"
});
require('fs').writeFileSync(`${name}.zip`, Buffer.from(response.data));
require('child_process').execSync(`unzip -o ${name}.zip -d ./${jobId}`);
};

View File

@@ -0,0 +1,11 @@
module.exports = async ({ github, context }) => {
const { data: runs } = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "build.yml",
branch: "main",
status: "success",
per_page: 1,
});
return runs.workflow_runs[0].id;
};

View File

@@ -0,0 +1,3 @@
module.exports = async ({ github, context, core, jobId }) => {
}