Generate Daily Markdown workflow (ViggoZ/producthunt-daily-hot)
The Generate Daily Markdown workflow from ViggoZ/producthunt-daily-hot, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Generate Daily Markdown workflow from the ViggoZ/producthunt-daily-hot repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Generate Daily Markdown
on:
schedule:
- cron: '01 7 * * *' # 每天UTC时间早上7:01(北京时间下午3:01自动运行)
workflow_dispatch: # 手动触发
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install openai>=1.0.0 python-dotenv beautifulsoup4 pytz requests
pip install python-wordpress-xmlrpc
pip list # 显示已安装的包及其版本
- name: Generate Markdown
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PRODUCTHUNT_DEVELOPER_TOKEN: ${{ secrets.PRODUCTHUNT_DEVELOPER_TOKEN }}
run: |
python scripts/product_hunt_list_to_md.py
- name: Commit files
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Generated daily content" || echo "No changes to commit"
- name: Push changes
run: |
git push --force https://${{ secrets.PAT }}@github.com/${{ github.repository_owner }}/producthunt-daily-hot.git HEAD:mainThe same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Generate Daily Markdown on: schedule: - cron: '01 7 * * *' # 每天UTC时间早上7:01(北京时间下午3:01自动运行) workflow_dispatch: # 手动触发 jobs: build: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Checkout repository uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: cache: 'pip' python-version: '3.x' - name: Install dependencies run: | pip install --upgrade pip pip install -r requirements.txt pip install openai>=1.0.0 python-dotenv beautifulsoup4 pytz requests pip install python-wordpress-xmlrpc pip list # 显示已安装的包及其版本 - name: Generate Markdown env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} PRODUCTHUNT_DEVELOPER_TOKEN: ${{ secrets.PRODUCTHUNT_DEVELOPER_TOKEN }} run: | python scripts/product_hunt_list_to_md.py - name: Commit files run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add . git commit -m "Generated daily content" || echo "No changes to commit" - name: Push changes run: | git push --force https://${{ secrets.PAT }}@github.com/${{ github.repository_owner }}/producthunt-daily-hot.git HEAD:main
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.