From b9560c21e635c0df35614738b31d2849e60401a8 Mon Sep 17 00:00:00 2001 From: Ara Yeressian Date: Fri, 26 Jun 2020 11:45:42 +0400 Subject: [PATCH] added logs --- src/index.ts | 3 ++- src/uploader.ts | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index df9765a..08b688a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import uploader from './uploader'; -import { getInput, setFailed } from '@actions/core'; +import { getInput, setFailed, info } from '@actions/core'; import { join } from 'path'; import { Utils } from '@technote-space/github-action-helper'; @@ -8,6 +8,7 @@ async function run() { const source = join(Utils.getWorkspace(), getInput('source')); const storageZoneName = getInput('storageZoneName'); const accessKey = getInput('accessKey'); + info(`Deploying ${source}`); await uploader(source, storageZoneName, accessKey); } catch (error) { setFailed(error.message); diff --git a/src/uploader.ts b/src/uploader.ts index 8c26233..1a8f65d 100644 --- a/src/uploader.ts +++ b/src/uploader.ts @@ -1,13 +1,14 @@ import fs from 'fs'; import fetch from 'node-fetch'; import readdirp from 'readdirp'; +import { info } from '@actions/core'; function uploadFile(entry: readdirp.EntryInfo, storageName: string, accessKey: string) { const stats = fs.statSync(entry.fullPath); const fileSizeInBytes = stats.size; let readStream = fs.createReadStream(entry.fullPath); - console.log(entry); + info(`Deploying ${entry.path}`); return fetch(`https://storage.bunnycdn.com/${storageName}/${entry.path}`, { method: 'POST', headers: { @@ -15,6 +16,11 @@ function uploadFile(entry: readdirp.EntryInfo, storageName: string, accessKey: s "Content-length": fileSizeInBytes.toString() }, body: readStream + }).then(response => { + if (response.status === 200) { + info(`Successfull deployment of ${entry.path}`); + } + return response; }); }