File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Publish article
2
+
3
+ on :
4
+ push :
5
+ branches : ['main']
6
+
7
+ jobs :
8
+ check-unpublished :
9
+ runs-on : ubuntu-latest
10
+ outputs :
11
+ should_publish : ${{ steps.should-publish.outputs.should_publish }}
12
+ steps :
13
+ - name : Checkout
14
+ uses : actions/checkout@v3
15
+ - name : Should publish
16
+ id : should-publish
17
+ run : echo "should_publish=$([[ -d "content/posts/unpublished" ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
18
+
19
+ publish :
20
+ runs-on : ubuntu-latest
21
+ needs : check-unpublished
22
+ if : ${{ needs.check-unpublished.outputs.should_publish == 'true' }}
23
+ steps :
24
+ - name : Checkout
25
+ uses : actions/checkout@v3
26
+ with :
27
+ token : ${{ secrets.BOSS_TOKEN }}
28
+ - uses : actions/setup-node@v3
29
+ with :
30
+ node-version : 20
31
+ - name : Move article to current date directory
32
+ run : |
33
+ npm ci
34
+ npm run build:utils
35
+ npm run posts:publish
36
+
37
+ - name : Commit changes
38
+ run : |
39
+ git config --local user.email "oss@backbase.com"
40
+ git config --local user.name "backbaseoss"
41
+ git add content
42
+ git commit -m "[BOT] Post published"
43
+
44
+ - name : Push changes
45
+ uses : ad-m/github-push-action@master
46
+ with :
47
+ github_token : ${{ secrets.BOSS_TOKEN }}
48
+ branch : ${{ github.ref }}
Original file line number Diff line number Diff line change @@ -22,8 +22,21 @@ concurrency:
22
22
cancel-in-progress : false
23
23
24
24
jobs :
25
+ check-unpublished :
26
+ runs-on : ubuntu-latest
27
+ outputs :
28
+ should_deploy : ${{ steps.should-publish.outputs.should_deploy }}
29
+ steps :
30
+ - name : Checkout
31
+ uses : actions/checkout@v3
32
+ - name : Should publish
33
+ id : should-publish
34
+ run : echo "should_deploy=$([[ -d "content/posts/unpublished" ]] && echo false || echo true)" >> "$GITHUB_OUTPUT"
35
+
25
36
# Single deploy job since we're just deploying
26
37
deploy :
38
+ needs : check-unpublished
39
+ if : ${{ needs.check-unpublished.outputs.should_deploy == 'true' }}
27
40
environment :
28
41
name : github-pages
29
42
url : ${{ steps.deployment.outputs.page_url }}
Original file line number Diff line number Diff line change @@ -69,6 +69,11 @@ async function moveUnpublishedDirectory(sourcePath, destinationRoot) {
69
69
70
70
// Remove the "unpublished" directory
71
71
fs . rmdirSync ( unpublishedPath ) ;
72
+
73
+ if ( isDirectoryEmpty ( sourcePath ) ) {
74
+ fs . rmdirSync ( sourcePath ) ;
75
+ }
76
+
72
77
console . log ( 'Unpublished directory removed.' ) ;
73
78
} else {
74
79
console . log ( 'No "unpublished" directory found.' ) ;
@@ -90,3 +95,13 @@ main();
90
95
function loadEsmModule ( modulePath ) {
91
96
return new Function ( 'modulePath' , `return import(modulePath);` ) ( modulePath ) ;
92
97
}
98
+
99
+ function isDirectoryEmpty ( path ) {
100
+ let empty = false ;
101
+ if ( fs . existsSync ( path ) ) {
102
+ const files = fs . readdirSync ( path ) ;
103
+ empty = ! files ?. length
104
+ }
105
+ return empty ;
106
+ }
107
+
You can’t perform that action at this time.
0 commit comments