Giter Site home page Giter Site logo

diary-generator-worker's Introduction

Diary Generator Worker

This is a CloudFlare Worker responsible for assisting in deploying a diary generated by Diary Generator if it's hosted on CloudFlare Pages.

On top of the usual CloudFlare pages built-in automatic deploying on push events, this worker runs every day at 00:00 causing a redeployment, allowing the diary generator to publish any new entries that needs publishing.
It also expects GitHub release event webhooks to a /github endpoint; on a new release being published this will also cause a redeployment of the diary. This is used to automatically listen to new releases of diary generator itself.

The code in this codebase does all of this for Game Dev Diary but it can be setup to be used for other diaries. If you would like to setup your own copy of all this shenanigans feel free to reach out! You will likely need me to set up a webhook for you on Diary Generator since GitHub allows only repository owners to set up webhooks.
Or you set it up to only do the daily re-deployments

Setup

There are currently 3 environmental variables and 4 secrets necessary to run this worker.

Envs:

  • ACCOUNT_ID the account id where the pages deployment lives
  • PROJECT_NAME the project name for the pages deployment
  • DISCORD_WEBHOOK_ID by default this project logs its messages via a Discord webhook since CloudFlare workers have no log retention. This is that webhook's id

Secrets:

  • EMAIL the email of the account where the pages deployment lives
  • AUTH_KEY the global authorization key for the account where the pages deployment lives
  • WEBHOOK_SECRET the secret setup for the GitHub webhook used for signing and verifying the webhook requests
  • DISCORD_WEBHOOK_TOKEN the Discord webhook's token

Contributing

This project uses deno for everything! (and wrangler of course is needed, the more Rust the merrier after all). First project for me using deno ever and it was very much a pleasure to use. In fact there was an iteration of this project originally in Node that I gave up on quickly because I didn't feel like setting up jest and babel just to be able to run my tests.

To run tests:

deno test tests/

To build:

wrangler build
# or
mkdir -p target && deno bundle src/worker.ts target/worker.js

To format

deno fmt

To lint

deno lint

All without any complex build configurations! Thanks to Deno maintainers for the lovely project ❤️

Trivia

Although CloudFlare recently related an update to pages to allow them to include a worker alongside them, it's still lacking in a lot of features (for example setting up secrets). So I went with keeping this in its own repository for now, it's also a bit simpler here since pages have a limited amount of monthly builds while workers can be deployed infinitely for free so we wouldn't wanna waste our builds to update the worker.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in diary generator by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.