diff --git a/.github/workflows/fetch-blog.yml b/.github/workflows/fetch-blog.yml index 39b925a7ab5..21ac09b20da 100644 --- a/.github/workflows/fetch-blog.yml +++ b/.github/workflows/fetch-blog.yml @@ -1,14 +1,23 @@ -name : Fetch Blog +name: Fetch Blog on: schedule: - - cron: '12 1 * * *' + - cron: "12 * * * *" jobs: cron: runs-on: ubuntu-latest steps: - - name: Call our API route - run: | - curl --request POST \ - --url 'https://taiko.xyz/api/getPosts' \ No newline at end of file + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Install pnpm dependencies + uses: ./.github/actions/install-pnpm-dependencies + + - name: Run getPosts + run: node packages/website/getPosts.js \ No newline at end of file diff --git a/packages/website/pages/api/getPosts.js b/packages/website/getPosts.js similarity index 91% rename from packages/website/pages/api/getPosts.js rename to packages/website/getPosts.js index f8450ad2457..a16166eb222 100644 --- a/packages/website/pages/api/getPosts.js +++ b/packages/website/getPosts.js @@ -7,7 +7,7 @@ const arweave = Arweave.init({ protocol: "https", }); -export default async function getTransanctionIds(req, res) { +async function getTransanctionIds() { await fetch("https://arweave.net/graphql", { method: "POST", headers: { @@ -48,7 +48,6 @@ export default async function getTransanctionIds(req, res) { .then((response) => { getPosts(response); }) - .finally(() => res.send(200)) .catch(); } @@ -70,9 +69,14 @@ async function getPosts(response) { }) .then(() => { const jsonString = JSON.stringify(posts); - fs.writeFile("./public/posts.json", jsonString, (err) => {}); + fs.writeFile( + "packages/website/public/posts.json", + jsonString, + (err) => {} + ); }) .catch(); }) ); } +getTransanctionIds();