name: render potyarkin.ml

on:
  push:
    branches:
      - smallweb
  schedule:
    - cron: 45 4,16 * * *

jobs:
  render:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/cache@v3
        with:
          path: cache/pip
          key: pip-${{ hashFiles('requirements.txt') }}
      - uses: actions/cache@v3
        with:
          path: cache/webring
          key: webring-${{ hashFiles('content/blogroll.yml') }}
      - run: make publish
        env:
          PIP_CACHE_DIR: cache/pip
      - uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: html
          publish_branch: html
          commit_message: |-
            render: ${{ github.event.head_commit.message }}

            Render static website for GitHub pages from
            commit

name: render potyarkin.ml

on:
  push:
    branches:
      - smallweb
  schedule:
    - cron: 45 4,16 * * *

jobs:
  render:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: get current date for cache keys
        id: date
        run: |-
          echo "::set-output name=date::$(/bin/date -u '+%Y%m%d')"
          echo "::set-output name=month::$(/bin/date -u '+%Y%m')"
      - uses: actions/cache@v3
        name: pip cache
        with:
          path: cache/pip
          key: pip-${{ hashFiles('requirements.txt') }}-${{ steps.date.outputs.month }}
          restore-keys: |
            pip-${{ hashFiles('requirements.txt') }}
            pip-
      - uses: actions/cache@v3
        name: webring cache
        with:
          path: cache/webring
          key: webring-${{ hashFiles('content/blogroll.yml') }}-${{ steps.date.outputs.date }}
          restore-keys: |
            webring-${{ hashFiles('content/blogroll.yml') }}
            webring-
      - run: make publish
        env:
          PIP_CACHE_DIR: cache/pip
      - uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: html
          publish_branch: html
          commit_message: |-
            render: ${{ github.event.head_commit.message }}

            Render static website for GitHub pages from
            commit

Update GitHub Actions cache regularly
Update GitHub Actions cache regularly

If a cache hit on cache key occurs, GitHub Actions do not update cache
after workflow even if cache contents change.

We append timestamps to cache keys and use restore-keys to force cache
misses regularly (daily for webring cache and monthly for pip cache). With
restore-keys the cache is still restored from latest partial match, but
after the workflow is complete a new cache is saved under new full key.
