diff --git a/.github/commit.mjs b/.github/commit.mjs index 2a51670..c98f526 100644 --- a/.github/commit.mjs +++ b/.github/commit.mjs @@ -1,10 +1,18 @@ #!/usr/bin/env zx +const getOutput = ({ stdout }) => stdout; + await $`git config --local user.email "leonid.shutov.main@gmail.com"`; await $`git config --local user.name "leonid-shutov"`; await $`git add .`; -// workaround not to have extra symbols in commands with dashes +const getWorkingTreeStatus = () => $`git status --porcelain`.then(getOutput); + +if (!(await getWorkingTreeStatus())) { + echo("Nothing to commit"); + process.exit(0); +} + await $`git commit -m "UPDATE README"`; await $`git push`; diff --git a/.github/workflows/update-readme.mjs b/.github/workflows/update-readme.mjs index bf5944f..8640783 100644 --- a/.github/workflows/update-readme.mjs +++ b/.github/workflows/update-readme.mjs @@ -8,6 +8,5 @@ $.verbose = false; await $`cat init.vim >> README.md`; const end = "```"; await $`echo ${end} >> README.md`; - const commitMessage = "UPDATE README"; - await $`npx zx .github/commit.mjs --message "${commitMessage}"`; + await $`npx zx .github/commit.mjs`; })();