From d1b8703624deb50ae6fc341d0275cc1c94a11396 Mon Sep 17 00:00:00 2001 From: Robinson Zimmermann Date: Tue, 23 Apr 2024 09:42:11 +0200 Subject: [PATCH] Commit changes --- .github/workflows/merge.yml | 22 +++++++++++++++++++--- tools/publish/index.js | 15 +++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 1a37b12e..a2d0627e 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -15,11 +15,27 @@ jobs: uses: actions/checkout@v3 - name: Should publish id: should-publish - run: | - echo "should_publish=$([[ -d "content/posts/unpublished" ]] && echo true || echo false)" >> "$GITHUB_OUTPUT" + run: echo "should_publish=$([[ -d "content/posts/unpublished" ]] && echo true || echo false)" >> "$GITHUB_OUTPUT" publish: runs-on: ubuntu-latest needs: check-unpublished + if: ${{ needs.check-unpublished.outputs.should_publish }} steps: - - run: echo ${{ needs.check-unpublished.outputs.should_publish }} \ No newline at end of file + - name: Move article to current date directory + run: | + npm ci + npm run build:utils + npm run posts:publish + + - name: Commit changes + run: | + git config --local user.email "oss@backbase.com" + git config --local user.name "backbaseoss" + git commit -m "[BOT] Post published" -a + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} \ No newline at end of file diff --git a/tools/publish/index.js b/tools/publish/index.js index 7a81276f..a6360d35 100644 --- a/tools/publish/index.js +++ b/tools/publish/index.js @@ -1,5 +1,6 @@ const fs = require('fs'); const path = require('path'); +const { isEmpty } = require('rxjs'); function updateMetaDate(filePath) { try { @@ -82,6 +83,10 @@ function main() { moveUnpublishedDirectory(sourceDirectory, destinationRoot); + if (isEmpty(sourceDirectory)) { + fs.rmdirSync(sourceDirectory); + } + console.log('Process completed.'); } @@ -90,3 +95,13 @@ main(); function loadEsmModule(modulePath) { return new Function('modulePath', `return import(modulePath);`)(modulePath); } + +function isDirectoryEmpty(path) { + let empty = false; + if (fs.existsSync(path)) { + fs.readdir(dirname, (_, files) => { + empty = !files?.length + }); + } + return empty; +}