Skip to content

Commit

Permalink
Commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsonzimmermann committed Apr 23, 2024
1 parent cb9bc2c commit d1b8703
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
- 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 "[email protected]"
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 }}
15 changes: 15 additions & 0 deletions tools/publish/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs');
const path = require('path');
const { isEmpty } = require('rxjs');

function updateMetaDate(filePath) {
try {
Expand Down Expand Up @@ -82,6 +83,10 @@ function main() {

moveUnpublishedDirectory(sourceDirectory, destinationRoot);

if (isEmpty(sourceDirectory)) {
fs.rmdirSync(sourceDirectory);
}

console.log('Process completed.');
}

Expand All @@ -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;
}

0 comments on commit d1b8703

Please sign in to comment.