Compare commits
19 Commits
refactor-i
...
7933a62f3a
Author | SHA1 | Date | |
---|---|---|---|
7933a62f3a
|
|||
2e271692b0
|
|||
ad5a6efa14
|
|||
b0725e8219
|
|||
7b50736f64
|
|||
a114309427
|
|||
8c4feac99a
|
|||
d9aa117ac6
|
|||
dbd765cbdf
|
|||
c69726c600
|
|||
14f1218845
|
|||
368ba86559
|
|||
dd929af281
|
|||
ddd15b4063
|
|||
a312781dc7
|
|||
7f5df4a59e
|
|||
9be17fd1a0
|
|||
bc56766110
|
|||
0537c5a914
|
40
index.js
40
index.js
@ -90,36 +90,52 @@ async function postCode() {
|
|||||||
|
|
||||||
const files_to_push = await readFilesIntoDict(pattern, prefix);
|
const files_to_push = await readFilesIntoDict(pattern, prefix);
|
||||||
|
|
||||||
|
core.info(`Trying to upload the following files to ${branch}:`);
|
||||||
Object.keys(files_to_push).forEach((key) => {
|
Object.keys(files_to_push).forEach((key) => {
|
||||||
core.info(`Key: ${key}`);
|
core.info(`Key: ${key}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
core.info(files_to_push);
|
|
||||||
|
|
||||||
const login_arguments = {
|
const login_arguments = {
|
||||||
token: token,
|
token: token,
|
||||||
username: username,
|
|
||||||
password: password,
|
|
||||||
protocol: protocol,
|
protocol: protocol,
|
||||||
hostname: hostname,
|
hostname: hostname,
|
||||||
port: port,
|
port: port,
|
||||||
path: path,
|
path: path,
|
||||||
|
username: "NameVergessen",
|
||||||
|
password: password,
|
||||||
};
|
};
|
||||||
|
|
||||||
core.info(`Trying to upload the following files to ${branch}:`);
|
core.info("login_arguments:");
|
||||||
Object.keys(login_arguments).forEach((key) => {
|
core.info(JSON.stringify(login_arguments, null, 2));
|
||||||
core.info(`Key: ${key}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
const errorMessage = validateAuthentication(token, username, password);
|
const errorMessage = validateAuthentication(token, username, password);
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
core.error(errorMessage);
|
core.error(errorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let api = new ScreepsAPI(login_arguments);
|
||||||
const api = new ScreepsAPI(login_arguments);
|
if (token) {
|
||||||
const response = await api.code.set(branch, files_to_push);
|
const response = await api.code.set(branch, files_to_push);
|
||||||
core.info(JSON.stringify(response, null, 2));
|
core.info(JSON.stringify(response, null, 2));
|
||||||
|
} else {
|
||||||
|
core.info(`Logging into as user ${username}`);
|
||||||
|
// await api.auth(username, password, login_arguments));
|
||||||
|
// await api.auth(username, password, login_arguments));
|
||||||
|
const response = Promise.resolve()
|
||||||
|
.then(() => api.auth(username, password, login_arguments))
|
||||||
|
.then(() => {
|
||||||
|
return api.code.set(branch, files_to_push);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
console.log("Code set successfully");
|
||||||
|
// Additional actions after setting the code, if necessary
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("Error:", err);
|
||||||
|
});
|
||||||
|
core.info("Authorized!");
|
||||||
|
core.info(JSON.stringify(response, null, 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
postCode();
|
postCode();
|
||||||
|
Reference in New Issue
Block a user