Skip to content

Commit

Permalink
fix(index): add debug for difference in days and remove unprocessed o…
Browse files Browse the repository at this point in the history
…ptions
  • Loading branch information
tuunit committed Mar 28, 2024
1 parent 4b7c756 commit df0cab2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20485,16 +20485,20 @@ const commitFile = async (emptyCommit = false) => {
* @returns {Promise<void>}
* */
const createEmptyCommit = async () => {
const { lastCommitDate } = await exec(
"git",
["--no-pager", "log", "-1", "--format=%ct"],
{ encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] },
);
const { lastCommitDate } = await exec("git", [
"--no-pager",
"log",
"-1",
"--format=%ct",
]);

const commitDate = new Date(parseInt(lastCommitDate, 10) * 1000);
const diffInDays = Math.round(
(new Date() - commitDate) / (1000 * 60 * 60 * 24),
);

core.debug(`Difference in days: ${diffInDays}`);

if (diffInDays > 50) {
core.info("Create empty commit to keep workflow active");
await commitFile(true);
Expand Down
14 changes: 9 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,20 @@ const commitFile = async (emptyCommit = false) => {
* @returns {Promise<void>}
* */
const createEmptyCommit = async () => {
const { lastCommitDate } = await exec(
"git",
["--no-pager", "log", "-1", "--format=%ct"],
{ encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] },
);
const { lastCommitDate } = await exec("git", [
"--no-pager",
"log",
"-1",
"--format=%ct",
]);

const commitDate = new Date(parseInt(lastCommitDate, 10) * 1000);
const diffInDays = Math.round(
(new Date() - commitDate) / (1000 * 60 * 60 * 24),
);

core.debug(`Difference in days: ${diffInDays}`);

if (diffInDays > 50) {
core.info("Create empty commit to keep workflow active");
await commitFile(true);
Expand Down

0 comments on commit df0cab2

Please sign in to comment.