Harems-io / Rarity-tools-clone

We can build our own.
6 stars 9 forks source link

restructure site into /src directory, refactor open sea data pulling, and periodically rebuild thru GitHub actions #9

Closed nresh closed 3 years ago

nresh commented 3 years ago

Changes

About the new GitHub Action

basically every 4 hours the cron job defined in .github/workflows/scheduled-builds.yml will send a POST request to a netlify webhook endpoint that triggers netlify to rebuild the site.

rebuilding the site in this way causes open sea data to be repulled and used as static content on the site. the existing redis cache is also refreshed (though currently it is only used in the dev environment for quick testing purposes).

in the future, instead of rebuilding the site, the github action cronjob should trigger a dedicated serverless function that would repull the data and replenish the cache. at that point we can go back to using the redis cache for the data. the method used in this pr was the quickest way to make sure that the page automatically reloads open sea data every 4 hours, without having to build/deploy any new serverless functions.

finally, in order to trigger another netlify site to rebuild (currently it is set to only rebuild my netlify app https://adoring-morse-060187.netlify.app, you will have to update line 15 of .github/workflows/scheduled-builds.yml to be:

run: curl -X POST -d {} https://api.netlify.com/build_hooks/{{your_hook_id_here}}

your hook id can be found after you create the hook in the netlify interface:

add_deploy_hook

this github action will run only one time to set up the cronjob and you can see if it worked in the Github interface for the repo, under "Actions":

Screen Shot 2021-08-21 at 3 16 12 PM
netlify[bot] commented 3 years ago

✔️ Deploy Preview for musing-dubinsky-a9f357 ready!

🔨 Explore the source changes: c7c02f42cc0f11eaea1330b8c3a4d73a131fa486

🔍 Inspect the deploy log: https://app.netlify.com/sites/musing-dubinsky-a9f357/deploys/61217a0ecb196e0007c1efde

😎 Browse the preview: https://deploy-preview-9--musing-dubinsky-a9f357.netlify.app