Skip to content

Commit

Permalink
Add debug statements, improve error messages (adding stack to debug…
Browse files Browse the repository at this point in the history
… handler)
  • Loading branch information
auguwu committed Apr 18, 2024
1 parent f26ae2d commit ba73779
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
23 changes: 23 additions & 0 deletions build/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -6825,6 +6825,29 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

@noelware/utils
MIT
Copyright (c) 2021-2024 Noelware, LLC. <team@noelware.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


@smithy/abort-controller
Apache-2.0
Apache License
Expand Down
2 changes: 1 addition & 1 deletion build/action.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions build/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@noelware/s3-action",
"description": "☕ Simple and fast GitHub Action to upload objects to Amazon S3 easily",
"version": "2.2.5",
"version": "2.2.6",
"type": "module",
"author": "Noel Towa <cutie@floofy.dev>",
"private": true,
Expand Down
27 changes: 19 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
*/

import { create as createGlobPattern } from '@actions/glob';
import { setFailed, warning, info } from '@actions/core';
import { warning, info, debug, error, ExitCode } from '@actions/core';
import { createReadStream } from 'fs';
import { join, resolve } from 'path';
import { assertIsError } from '@noelware/utils';
import { upload, init } from './s3';
import { inferOptions } from './config';
import { basename } from 'node:path';
import { readdir } from 'node:fs/promises';
import { resolve } from 'path';
import { lstat } from 'node:fs/promises';
import { EOL } from 'node:os';

async function main() {
const config = await inferOptions();
Expand All @@ -57,18 +57,18 @@ async function main() {
continue;
}

const files = await readdir(d).then((files) => files.map((s) => `${d}${EOL}${s}`));
const files = await readdir(d).then((files) => files.map((s) => join(d, s)));
for (const file of files) {
const filename = basename(file);
if (excluded.includes(filename)) continue;
debug(`Uploading file ${file} (from directory ${d})`);
if (excluded.includes(file)) continue;

await upload({
pathFormat: config.pathFormat,
partSize: config.partSize,
prefix: config.prefix,
bucket: config.bucket,
stream: createReadStream(file),
file: filename,
file: basename(file),
acl: config.objectAcl
});
}
Expand All @@ -93,4 +93,15 @@ async function main() {
}
}

main().catch((ex) => setFailed(ex));
main().catch((ex) => {
try {
assertIsError(ex);

error(`failed to run \`noelware/s3-action\`: ${ex.message}`);
if (ex.stack) debug(ex.stack);
} catch {
error(`failed to run \`noelware/s3-action\`: ${JSON.stringify(ex)}`);
}

process.exitCode = ExitCode.Failure;
});

0 comments on commit ba73779

Please sign in to comment.