Skip to content

Commit

Permalink
Built 🚜
Browse files Browse the repository at this point in the history
  • Loading branch information
aldoyh committed Jul 18, 2023
1 parent 2ff714a commit 43b2f89
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 22 deletions.
69 changes: 59 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 () => {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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",
Expand Down
9 changes: 0 additions & 9 deletions pnpm-lock.yaml

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

0 comments on commit 43b2f89

Please sign in to comment.