diff --git a/.github/workflows/save_articles.yml b/.github/workflows/save_articles.yml index 063b166..ec2b943 100644 --- a/.github/workflows/save_articles.yml +++ b/.github/workflows/save_articles.yml @@ -19,5 +19,5 @@ jobs: uses: ./ # Path to the directory containing the action.yml with: devApiKey: ${{ secrets.DEV_TOKEN }} - outputDir: "./articles" + # outputDir: "./" branch: "core_functionalities" diff --git a/dist/index.js b/dist/index.js index 955b722..54aebff 100644 --- a/dist/index.js +++ b/dist/index.js @@ -46,7 +46,7 @@ async function DevSync() { } const apiKey = core.getInput("devApiKey"); const outputDir = core.getInput("outputDir") || "/"; // Default is the root directory - const branch = core.getInput("branch"); + const branch = core.getInput("branch") || "main"; const conventionalCommits = core.getInput("conventional_commits") === "true"; const articles = await (0, fetchDevToArticles_1.fetchDevToArticles)(apiKey); (0, createMarkdownFile_1.createMarkdownFile)(articles, outputDir, branch, conventionalCommits); @@ -123,11 +123,14 @@ created_at: "${article.published_timestamp}" --- `; + core.notice("start of file path"); fs.writeFileSync(filePath, markdownContent); // Commit and push the new markdown file to the specified branch - // await gitAdd(filePath) - // await gitCommit(commitMessage, gitConfig) - // await gitPush(branch, gitConfig) + await (0, git_1.gitAdd)(filePath); + core.notice("Attempting to add files to git..."); + await (0, git_1.gitCommit)(commitMessage, git_1.gitConfig); + core.notice("Files added to git."); + await (0, git_1.gitPush)(branch, git_1.gitConfig); core.notice(`Markdown file created and committed: ${filePath}`); } else { diff --git a/dist/utils/createMarkdownFile.js b/dist/utils/createMarkdownFile.js index da04a5d..d5449db 100644 --- a/dist/utils/createMarkdownFile.js +++ b/dist/utils/createMarkdownFile.js @@ -56,11 +56,14 @@ created_at: "${article.published_timestamp}" --- `; + core.notice("start of file path"); fs.writeFileSync(filePath, markdownContent); // Commit and push the new markdown file to the specified branch - // await gitAdd(filePath) - // await gitCommit(commitMessage, gitConfig) - // await gitPush(branch, gitConfig) + await (0, git_1.gitAdd)(filePath); + core.notice("Attempting to add files to git..."); + await (0, git_1.gitCommit)(commitMessage, git_1.gitConfig); + core.notice("Files added to git."); + await (0, git_1.gitPush)(branch, git_1.gitConfig); core.notice(`Markdown file created and committed: ${filePath}`); } else { diff --git a/src/index.ts b/src/index.ts index ec260b1..70746c7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ async function DevSync() { const apiKey = core.getInput("devApiKey") const outputDir = core.getInput("outputDir") || "/" // Default is the root directory - const branch = core.getInput("branch") + const branch = core.getInput("branch") || "main" const conventionalCommits = core.getInput("conventional_commits") === "true" const articles = await fetchDevToArticles(apiKey) diff --git a/src/utils/createMarkdownFile.ts b/src/utils/createMarkdownFile.ts index 1060599..271b7e3 100644 --- a/src/utils/createMarkdownFile.ts +++ b/src/utils/createMarkdownFile.ts @@ -47,16 +47,17 @@ created_at: "${article.published_timestamp}" ` + core.notice("start of file path") fs.writeFileSync(filePath, markdownContent) // Commit and push the new markdown file to the specified branch await gitAdd(filePath) - console.log("Attempting to add files to git...") + core.notice("Attempting to add files to git...") await gitCommit(commitMessage, gitConfig) - console.log("Files added to git.") + core.notice("Files added to git.") await gitPush(branch, gitConfig) core.notice(`Markdown file created and committed: ${filePath}`)