Skip to content

Commit

Permalink
chore: Better Logging (#40)
Browse files Browse the repository at this point in the history
* chore: Better Logging

* update dist
  • Loading branch information
therynamo authored Mar 28, 2022
1 parent 04ce776 commit 18da1ca
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
17 changes: 16 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

32 changes: 26 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ export async function run(): Promise<void> {
let filteredTicketIds = ticketIds ?? [];

if (ignoredKeys.length) {
core.info(`Filtering based on ignored keys input: ${ignoredKeys}`);
filteredTicketIds = filteredTicketIds?.filter((ticket) => !ignoredKeys.some((ignore) => ticket?.includes(ignore)));
}

if (projectKeys.length) {
core.info(`Filtering based on project keys input: ${projectKeys}`);

filteredTicketIds = ticketIds?.filter((ticket) => projectKeys.some((projectKey) => ticket?.includes(projectKey))) ?? [];
}

Expand All @@ -80,12 +83,21 @@ export async function run(): Promise<void> {
return;
}

await createEmptyCommitWithMessage({
...context.repo,
message: `${filteredTicketIds[0]}` ?? '',
branch: pull_request?.head?.ref,
octokit,
});
core.info(`Creating commit for ${filteredTicketIds[0]}`);

try {
await createEmptyCommitWithMessage({
...context.repo,
message: `${filteredTicketIds[0]}` ?? '',
branch: pull_request?.head?.ref,
octokit,
});
} catch (error) {
core.error(`Failed on ${filteredTicketIds[0]}. Has been committed? ${hasCommittedAlready}: ${error}`);
setFailed(`Failed on ${filteredTicketIds[0]}. Has been committed? ${hasCommittedAlready}: ${error}`);
}

core.info(`Succeeded in committing for ${filteredTicketIds[0]}`);
}

let newRef = '';
Expand All @@ -104,6 +116,7 @@ export async function run(): Promise<void> {
});
newRef = ref;
} catch (error) {
core.error(`Failed on ${ticketId} - ${hasCommittedAlready}: ${error}`);
setFailed(`Failed on ${ticketId} - ${hasCommittedAlready}: ${error}`);
}
}
Expand All @@ -112,13 +125,20 @@ export async function run(): Promise<void> {
for (let i = 0; i < filteredTicketIds.length; i++) {
const isLastMessage = i !== (filteredTicketIds as string[])?.length - 1;
try {
core.info(`Creating commit for ${filteredTicketIds[i]}`);

await batchedCommit({ ticketId: (filteredTicketIds as string[])[i], isLastMessage });

core.info(`Succeeded in committing for ${filteredTicketIds[i]}`);
} catch (error) {
core.info(`Failed in committing for ${filteredTicketIds[i]}`);
console.log({ error });
}
}
} catch (error) {
if (error instanceof Error) setFailed(error.message);

core.error(`${error}`);
}
}

Expand Down

0 comments on commit 18da1ca

Please sign in to comment.