Advent of Cancer

friend of mine had the idea of doing something along the lines of advent of code, but in his style.

The idea is to have 24 unique coding challenges that all require some sort of unorthodox solution. They should be easily accessible and need to be available from their respective day on.
So I decided to help him out by teaching him how to use GitHub Actions and Cloudflare pages to host an auto-updating website. Read the rest, if you'd like to learn how to do that as well.

The first step is to create a private GitHub repository for the website and updating code to live in. If you don't need the code the be private, you can also use a public repo and host using GitHub Pages.

Once that's done, you need to link that repo to a new Cloudflare page under
Workers & Pages -> Overview -> Pages -> Connect to Git
In there, you'll need to create an index.html and a workflow file in .github/workflows/push_daily.yml:

on:
    workflow_dispatch:
    schedule:
        - cron: "0 0 * 12 *"

jobs:
    build:
        runs-on: ubuntu-latest
        permissions:
            # Give the default GITHUB_TOKEN write permission to commit and push the
            # added or changed files to the repository.
            contents: write
        steps:
        - name: checkout
          uses: actions/checkout@v4
        - name: get day in month
          id: get_day
          run: echo "::set-output name=day::$(date +'%d')"
        - name: copy folder day[day]
          run: mv day$ prod
        - uses: stefanzweifel/git-auto-commit-action@v5

This specific workflow runs either manually, by workflow_dispatch or every day in December on 00:00 UTC.
It runs on a GitHub provided runner and has write permission to the content of the repo.
First, it just checks out the repo using actions/checkout@v4.
Then it uses date +'%d' to get the current day in the month (eg 02) and writes it into the day variable.
steps.get_day.outputs.day can then be used to move the corresponding folder into the prod folder, which will be deployed by Cloudflare.
The last step is to use stefanzweifel/git-auto-commit-action@v5 to commit the changes, which will be picked up by Cloudflare and deployed to the website.