File tree Expand file tree Collapse file tree 2 files changed +21
-30
lines changed Expand file tree Collapse file tree 2 files changed +21
-30
lines changed Original file line number Diff line number Diff line change 1
- name : Generate lastposts.json
2
-
1
+ name : Crear nuevo post
3
2
on :
4
3
push :
5
- paths :
6
- - ' _posts/**' # Solo se ejecuta cuando hay cambios en esta carpeta
7
-
4
+ branches : [ master ]
8
5
jobs :
9
- build :
6
+ crear-post :
10
7
runs-on : ubuntu-latest
11
-
12
8
steps :
13
- - name : Check out repository
14
- uses : actions/checkout@v2
15
-
16
- - name : Set up Node.js
17
- uses : actions/setup-node@v2
18
- with :
19
- node-version : ' 20' # Asegúrate de que tu versión de Node.js sea compatible
20
-
21
- - name : Install dependencies
22
- run : npm install
23
-
24
- - name : Generate lastposts.json
25
- run : node generateLastPosts.js
26
-
27
- - name : Commit lastposts.json
28
- run : |
29
- git config --global user.email "manyandacreaty@gmail.com"
30
- git config --global user.name "CodeInvers3"
31
- git add lastposts.json
32
- git commit -m "Update lastposts.json"
33
- git push
34
- env :
35
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9
+ - uses : actions/checkout@v4
10
+ - uses : actions/setup-node@v4
11
+ - run : npm install
12
+ - run : node addpost.js
Original file line number Diff line number Diff line change
1
+ const fs = require ( 'fs' ) ;
2
+
3
+ const newPost = {
4
+ title : 'Mi primer post' ,
5
+ content : 'Este es el contenido de mi primer post'
6
+ } ;
7
+
8
+ fs . writeFile ( 'post.json' , JSON . stringify ( newPost ) , ( err ) => {
9
+ if ( err ) {
10
+ console . error ( err ) ;
11
+ } else {
12
+ console . log ( 'Archivo post.json creado exitosamente' ) ;
13
+ }
14
+ } ) ;
You can’t perform that action at this time.
0 commit comments