Skip to content

Commit

Permalink
chore: check branch changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol-Baranwal committed Feb 14, 2024
1 parent 1086f81 commit f774e2a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/save_articles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 7 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions dist/utils/createMarkdownFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/utils/createMarkdownFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down

0 comments on commit f774e2a

Please sign in to comment.