From cf561424c98c6116033fd1a7bfd16b76f5674760 Mon Sep 17 00:00:00 2001 From: Thiago Mendonca Date: Mon, 21 Oct 2024 23:26:56 +0200 Subject: [PATCH] feat(*): final adjusts to publish to devTo --- .github/workflows/test.yml | 4 +++- .husky/pre-push | 2 +- action.yml | 2 +- dist/index.js | 7 ++++--- src/index.ts | 9 ++++++--- test/post-samples/markdown-example-1.md | 3 ++- test/post-samples/markdown-example-2.mdx | 7 +++---- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f314a6b..dab399f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,8 @@ jobs: uses: ./ # Uses an action in the root directory id: publish-blog-post with: + publishTo: 'devTo' devToApiKey: ${{ secrets.DEV_TO_API_KEY }} includeFolders: |- - pages/posts + test/post-samples + commitMessage: 'chore(*): publish/update %file with updated data' diff --git a/.husky/pre-push b/.husky/pre-push index 98475b5..1cb9a63 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1 +1 @@ -pnpm test +pnpm test:all diff --git a/action.yml b/action.yml index a69f346..267443a 100644 --- a/action.yml +++ b/action.yml @@ -11,7 +11,7 @@ inputs: publishTo: description: Websites to publish blog post. Current allowed values are 'devTo' and 'medium' required: true - default: 'devTo,medium' + default: 'devTo' devToApiKey: description: API Key to use to publish blog post to Dev.to website required: false diff --git a/dist/index.js b/dist/index.js index c6bc020..d45949a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -38218,13 +38218,14 @@ const main = async () => { await gitSetConfig(); const branch = await gitCheckout(); const commitMessage = getCommitMessage(ACTION_INPUT_KEY_COMMIT_MESSAGE_TEMPLATE); - modifiedFiles.forEach(async (fileName) => { + for (const fileName of modifiedFiles) { await gitCommit({ filePath: fileName, message: commitMessage.replace('%file', fileName), }); - }); - gitPush({ branch }); + } + await gitPush({ branch }); + logBuildInfo('Build completed successfully.'); }; main().catch(setBuildFailed); /* harmony default export */ const src = (main); diff --git a/src/index.ts b/src/index.ts index 26cc98f..159eedb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ import { gitCommit, gitPush, gitSetConfig, + logBuildInfo, setBuildFailed, } from '@/pbp/git'; import { parsePostFileContent } from '@/pbp/posts/content'; @@ -32,14 +33,16 @@ const main = async () => { const commitMessage = getCommitMessage(ACTION_INPUT_KEY_COMMIT_MESSAGE_TEMPLATE); - modifiedFiles.forEach(async fileName => { + for (const fileName of modifiedFiles) { await gitCommit({ filePath: fileName, message: commitMessage.replace('%file', fileName), }); - }); + } + + await gitPush({ branch }); - gitPush({ branch }); + logBuildInfo('Build completed successfully.'); }; main().catch(setBuildFailed); diff --git a/test/post-samples/markdown-example-1.md b/test/post-samples/markdown-example-1.md index f188624..b51b24c 100644 --- a/test/post-samples/markdown-example-1.md +++ b/test/post-samples/markdown-example-1.md @@ -2,9 +2,10 @@ title: A Brief History of the World published: false description: The earliest stages of human history are known as prehistory, marked by the development of tools, fire, and early communication through cave art. Humans lived as hunter-gatherers, with evidence of their existence found in Africa as early as 200,000 years ago. -tags: history, civilization, prehistory, modern +tags: history, civilization, world, modern cover_image: 'https://images.unsplash.com/photo-1521295121783-8a321d551ad2?q=80&w=2970&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D' published_at: null +devTo: false --- # A Brief History of the World diff --git a/test/post-samples/markdown-example-2.mdx b/test/post-samples/markdown-example-2.mdx index 052079a..3f6c468 100644 --- a/test/post-samples/markdown-example-2.mdx +++ b/test/post-samples/markdown-example-2.mdx @@ -1,12 +1,11 @@ --- title: Finding the Meaning of Life published: false -description: >- - Discover the profound question of life's purpose with the `life-meaning-finder` Node.js library. - Explore advanced algorithms and philosophical insights to uncover a unique and personalized understanding of existence. +description: Discover the profound question of life's purpose with the `life-meaning-finder` Node.js library. Explore advanced algorithms and philosophical insights to uncover a unique and personalized understanding of existence. tags: [philosophy, life, meaning, Node.js, library] cover_image: 'https://unsplash.com/pt-br/fotografias/pessoa-contemplando-o-significado-da-vida' -published_at: '2022-10-01T00:00:00.000Z' +published_at: null +devTo: false --- ## **Finding the Meaning of Life with `life-meaning-finder`**