From dc4591fb3e60462091c8bdb9c33915d3f2d2ca84 Mon Sep 17 00:00:00 2001 From: Nubenetes Bot Date: Fri, 19 Jun 2026 12:14:34 +0200 Subject: [PATCH] feat: cache news_digest.json by date to avoid re-calling Gemini on re-runs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Publisher and weekly digest workflows now restore news_digest.json from GitHub Actions cache using key news-digest-YYYY-MM-DD. If cache hits (same-day re-run after publisher failure), the Gemini digest step is skipped entirely — saving ~20min and Gemini API credits. Cache is saved immediately after successful generation and expires automatically after 7 days (GitHub Actions cache policy). Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/04.1.agentic_v2_publish.yml | 28 ++++++++++++++++++- .github/workflows/09.weekly_digest.yml | 26 +++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/.github/workflows/04.1.agentic_v2_publish.yml b/.github/workflows/04.1.agentic_v2_publish.yml index f505ea98..49e4188b 100644 --- a/.github/workflows/04.1.agentic_v2_publish.yml +++ b/.github/workflows/04.1.agentic_v2_publish.yml @@ -60,7 +60,20 @@ jobs: - name: Installation of Dependencies run: | pip install --no-cache-dir pydantic PyGithub httpx fake-useragent pytz python-dotenv pyyaml tenacity - + + - name: Get current date for digest cache key + id: digest-date + run: echo "date=$(date -u +%Y-%m-%d)" >> $GITHUB_OUTPUT + + - name: Restore News Digest Cache + id: cache-digest + uses: actions/cache/restore@v5 + with: + path: data/news_digest.json + key: news-digest-${{ steps.digest-date.outputs.date }} + restore-keys: | + news-digest- + - name: Execute Video Portal Generator env: PYTHONPATH: ${{ github.workspace }} @@ -87,14 +100,27 @@ jobs: python -u -m src.enrichment || echo "Enrichment pipeline skipped (no token or error)" - name: Generate News Digest + if: steps.cache-digest.outputs.cache-hit != 'true' env: PYTHONPATH: ${{ github.workspace }} GEMINI_API_KEY_1: ${{ secrets.GEMINI_API_KEY_1 }} GEMINI_API_KEY_2: ${{ secrets.GEMINI_API_KEY_2 }} run: | python -u -m src.news_digest || echo "News digest generation skipped (no API key or error)" + + - name: Generate RSS Feed + env: + PYTHONPATH: ${{ github.workspace }} + run: | python -u -m src.rss_generator || echo "RSS generation skipped" + - name: Save News Digest Cache + if: steps.cache-digest.outputs.cache-hit != 'true' && hashFiles('data/news_digest.json') != '' + uses: actions/cache/save@v5 + with: + path: data/news_digest.json + key: news-digest-${{ steps.digest-date.outputs.date }} + - name: Run V2 Publisher (Render-Only) env: PYTHONPATH: ${{ github.workspace }} diff --git a/.github/workflows/09.weekly_digest.yml b/.github/workflows/09.weekly_digest.yml index 6931c41d..cebfdf2c 100644 --- a/.github/workflows/09.weekly_digest.yml +++ b/.github/workflows/09.weekly_digest.yml @@ -33,13 +33,39 @@ jobs: - name: Install Dependencies run: pip install -r requirements.txt + - name: Get current date for digest cache key + id: digest-date + run: echo "date=$(date -u +%Y-%m-%d)" >> $GITHUB_OUTPUT + + - name: Restore News Digest Cache + id: cache-digest + uses: actions/cache/restore@v5 + with: + path: data/news_digest.json + key: news-digest-${{ steps.digest-date.outputs.date }} + restore-keys: | + news-digest- + - name: Generate News Digest (Gemini) + if: steps.cache-digest.outputs.cache-hit != 'true' env: PYTHONPATH: ${{ github.workspace }} GEMINI_API_KEY_1: ${{ secrets.GEMINI_API_KEY_1 }} GEMINI_API_KEY_2: ${{ secrets.GEMINI_API_KEY_2 }} run: | python -u -m src.news_digest + + - name: Save News Digest Cache + if: steps.cache-digest.outputs.cache-hit != 'true' && hashFiles('data/news_digest.json') != '' + uses: actions/cache/save@v5 + with: + path: data/news_digest.json + key: news-digest-${{ steps.digest-date.outputs.date }} + + - name: Generate RSS Feed + env: + PYTHONPATH: ${{ github.workspace }} + run: | python -u -m src.rss_generator || echo "RSS generation skipped" - name: Render V2 Portal (Digest Pages Only)