mirror of
https://github.com/trympet/nextcloud-artifacts-action.git
synced 2025-04-28 13:46:09 +02:00
test
This commit is contained in:
parent
353b719074
commit
71d45ee738
1441
dist/index.js
vendored
1441
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -31,12 +31,12 @@ export class NextcloudClient {
|
|||||||
this.headers = { 'Authorization': 'Basic ' + btoa(`${Inputs.Username}:${Inputs.Password}`) };
|
this.headers = { 'Authorization': 'Basic ' + btoa(`${Inputs.Username}:${Inputs.Password}`) };
|
||||||
this.davClient = webdav.createClient(`${this.endpoint}/remote.php/dav`, {
|
this.davClient = webdav.createClient(`${this.endpoint}/remote.php/dav`, {
|
||||||
username: Inputs.Username,
|
username: Inputs.Username,
|
||||||
password: Inputs.Password
|
password: Inputs.Password,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async uploadFiles(files: string[]) {
|
public async uploadFiles(files: string[]) {
|
||||||
core.info("Begin uploading files...");
|
core.info("Preparing upload...");
|
||||||
const spec = this.uploadSpec(files);
|
const spec = this.uploadSpec(files);
|
||||||
core.info("Zipping files...");
|
core.info("Zipping files...");
|
||||||
var zip = await this.zipFiles(spec);
|
var zip = await this.zipFiles(spec);
|
||||||
@ -150,17 +150,18 @@ export class NextcloudClient {
|
|||||||
|
|
||||||
private async upload(file: string) {
|
private async upload(file: string) {
|
||||||
const remoteFileDir = `/artifacts/${this.guid}`;
|
const remoteFileDir = `/artifacts/${this.guid}`;
|
||||||
|
core.info("Creating directory...");
|
||||||
if (!(await this.davClient.exists(remoteFileDir))) {
|
if (!(await this.davClient.exists(remoteFileDir))) {
|
||||||
await this.davClient.createDirectory(remoteFileDir, { recursive: true });
|
await this.davClient.createDirectory(remoteFileDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteFilePath = path.join(remoteFileDir, `${this.artifact}.zip`);
|
const remoteFilePath = path.join(remoteFileDir, `${this.artifact}.zip`);
|
||||||
const stream = fsSync.createReadStream(file);
|
core.info("Transferring file...");
|
||||||
const res = await this.davClient.putFileContents(remoteFilePath, stream, {
|
fsSync.createReadStream(file)
|
||||||
onUploadProgress: p => core.debug(`Progress: ${p.loaded}/${p.total}`),
|
.pipe(this.davClient.createWriteStream(remoteFilePath))
|
||||||
});
|
.on('error', () => core.setFailed("Failed to upload file"))
|
||||||
|
.on('finish', () => core.info("File upload finished"));
|
||||||
|
|
||||||
core.debug(`Upload status: ${res}`);
|
|
||||||
return remoteFilePath;
|
return remoteFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user