Closed nresh closed 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
Changes
this pr moves all the main code into a
src/
directory, in keeping with other js frameworks and for more easily distinguishing between config files and the source codethis pr also refactors the logic around pulling data from the OpenSea api and caching it by movinig logic into focused functions. this makes the code in
get-open-sea.js
easier to read and maintain.finally, this PR includes the use of github actions in to run a cron job that rebuilds the set every 4 hours. github workflow is defined in
.github/workflows/scheduled-builds.yml
.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:
your hook id can be found after you create the hook in the netlify interface:
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":