Skip to content

Commit 0218a31

Browse files
author
Invers3
committed
Add post.js
Testing
1 parent 01e0abb commit 0218a31

File tree

2 files changed

+21
-30
lines changed

2 files changed

+21
-30
lines changed

.github/workflows/lastposts.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,12 @@
1-
name: Generate lastposts.json
2-
1+
name: Crear nuevo post
32
on:
43
push:
5-
paths:
6-
- '_posts/**' # Solo se ejecuta cuando hay cambios en esta carpeta
7-
4+
branches: [ master ]
85
jobs:
9-
build:
6+
crear-post:
107
runs-on: ubuntu-latest
11-
128
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

addpost.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
});

0 commit comments

Comments
 (0)