From 43b2f89c1290ca2597909dd5806fd0f90423a3e2 Mon Sep 17 00:00:00 2001 From: Hasan Date: Tue, 18 Jul 2023 21:25:45 +0300 Subject: [PATCH] =?UTF-8?q?Built=20=F0=9F=9A=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/index.js | 69 ++++++++++++++++++++++++++++++++++++++++++-------- package.json | 5 ++-- pnpm-lock.yaml | 9 ------- 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9b9c84c..604c5da 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6207,9 +6207,15 @@ async function updateReadme(data) { if (newReadme !== readmeData) { core.info("Writing to " + README_FILE_PATH); fs.writeFileSync(README_FILE_PATH, newReadme); - if (!process.env.TEST_MODE) { - commitReadme(); - } + + // if (!process.env.TEST_MODE) { + // commitReadme(); + // } + + core.info("README.md updated 👔 Successfully"); + + // GitHub Action git push + } else { core.info("No change detected, skipping"); process.exit(0); @@ -6257,13 +6263,56 @@ const buildReadme = (prevReadmeContent, newReadmeContent) => { const commitReadme = async () => { // Getting config - await exec("git", ["add", README_FILE_PATH]); - await exec("git", ["commit", "-m", commitMessage]); - // await exec('git', ['fetch']); - // await exec("git", ["push"]); - core.info("Readme updated successfully."); - // Making job fail if one of the source fails - process.exit(jobFailFlag ? 1 : 0); + const gitConfig = { + email: core.getInput("GIT_EMAIL") || process.env.GIT_EMAIL, + username: core.getInput("GIT_USERNAME") || process.env.GIT_USERNAME, + rebase: core.getInput("REBASE") || process.env.REBASE, + branch: core.getInput("BRANCH") || process.env.BRANCH, + commit_message: + core.getInput("COMMIT_MESSAGE") || process.env.COMMIT_MESSAGE, + + // For testing + test_mode: process.env.TEST_MODE, + + // For debugging + debug: core.getInput("DEBUG") || process.env.DEBUG, + + }; + + // Setting up git + await exec("git config --global user.email", gitConfig.email); + + await exec("git config --global user.name", gitConfig.username); + + // Fetching the latest changes + await exec("git fetch"); + + // Checking out to the branch + await exec("git checkout", gitConfig.branch); + + // Rebasing + if (gitConfig.rebase === "true") { + await exec("git rebase origin", gitConfig.branch); + } + + // Committing the changes + await exec("git add ."); + + await exec("git commit -m", gitConfig.commit_message); + + // Pushing the changes + await exec("git push origin", gitConfig.branch); + + core.info("Changes committed to the branch"); + + // Checking if the commit was successful + const gitLog = await exec("git log -1 --pretty=%B"); + + if (gitLog.includes(gitConfig.commit_message)) { + core.info("Commit successful"); + } + + }; (async () => { diff --git a/package.json b/package.json index f431ae7..b2f4235 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "todoist-readme", - "version": "0.0.7", + "version": "0.0.9", "description": "🚧 Updates README with your Todoist stats", "main": "index.js", "dependencies": { @@ -11,8 +11,7 @@ "process": "^0.11.10" }, "devDependencies": { - "@vercel/ncc": "^0.36.1", - "@zeit/ncc": "^0.22.3" + "@vercel/ncc": "^0.36.1" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0d647b..f128b2d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,9 +25,6 @@ devDependencies: '@vercel/ncc': specifier: ^0.36.1 version: 0.36.1 - '@zeit/ncc': - specifier: ^0.22.3 - version: 0.22.3 packages: @@ -49,12 +46,6 @@ packages: hasBin: true dev: true - /@zeit/ncc@0.22.3: - resolution: {integrity: sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==} - deprecated: '@zeit/ncc is no longer maintained. Please use @vercel/ncc instead.' - hasBin: true - dev: true - /axios@0.20.0: resolution: {integrity: sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==} deprecated: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410