refactor: migrate to screeps-api v2 and update actions to node 22
Test / Run Tests (push) Failing after 1s
Recompile dist/ on Renovate PR / recompile (pull_request) Failing after 0s
Test / Run Tests (pull_request) Failing after 0s
Philipp/Global-Workflows: Pre-commit Lint (Scoped) / pre-commit (pull_request) Failing after 1s

This commit is contained in:
2026-09-04 23:56:04 +02:00
parent d644b19b47
commit cfb97819ae
8 changed files with 68 additions and 33 deletions
+18 -6
View File
@@ -1,4 +1,4 @@
import { ScreepsAPI } from "screeps-api";
import { ScreepsHttpClient } from "screeps-api";
import * as core from "@actions/core";
import fs from "fs";
import { glob } from "glob";
@@ -180,12 +180,16 @@ export async function postCode() {
core.error(errorMessage);
return;
}
let api = new ScreepsAPI(login_arguments);
let api = new ScreepsHttpClient(login_arguments);
if (!token) {
core.info(`Logging in as user ${username}`);
try {
await api.auth(username, password, login_arguments);
if (typeof api.authSignin === "function") {
await api.authSignin(username, password);
} else {
await api.auth(username, password, login_arguments);
}
} catch (err) {
core.error(`Authentication error: ${err}`);
throw err;
@@ -205,7 +209,9 @@ export async function postCode() {
`Downloading existing code from branch ${branch} for potential rollback...`,
);
try {
const getResponse = await api.code.get(branch);
const getResponse = await (api.userCodeGet
? api.userCodeGet(branch)
: api.code.get(branch));
if (getResponse && getResponse.ok && getResponse.modules) {
oldCode = getResponse.modules;
core.info(
@@ -226,7 +232,9 @@ export async function postCode() {
}
try {
const response = await api.code.set(branch, files_to_push);
const response = await (api.userCodeSet
? api.userCodeSet({ branch, modules: files_to_push })
: api.code.set(branch, files_to_push));
core.info(JSON.stringify(response, null, 2));
core.info(`Code set successfully to ${branch}`);
} catch (err) {
@@ -279,7 +287,11 @@ export async function postCode() {
"Action failed based on monitor configuration. Rolling back to previous code...",
);
try {
await api.code.set(branch, oldCode);
if (typeof api.userCodeSet === "function") {
await api.userCodeSet({ branch, modules: oldCode });
} else {
await api.code.set(branch, oldCode);
}
core.info(
`Successfully rolled back to previous code on branch ${branch}.`,
);