sync_douban workflow (Qliangw/notion_sync_data)
The sync_douban workflow from Qliangw/notion_sync_data, explained and optimized by Latchkey.
CI health: A - excellent
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the sync_douban workflow from the Qliangw/notion_sync_data 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: sync_douban
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
env:
USER_AGENT: ${{ secrets.USER_AGENT }}
USER_COOKIE: ${{ secrets.USER_COOKIE }}
DOUBAN_USER_ID: ${{ secrets.DOUBAN_USER_ID }}
DOUBAN_DAY: ${{ secrets.DOUBAN_DAY }}
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
NOTION_BOOKS_DB: ${{ secrets.NOTION_BOOKS_DB }}
NOTION_MUSIC_DB: ${{ secrets.NOTION_MUSIC_DB }}
NOTION_MOVIE_DB: ${{ secrets.NOTION_MOVIE_DB }}
NOTION_GAME_DB: ${{ secrets.NOTION_GAME_DB }}
jobs:
sync_douban:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: create config
run: cp doc/config.yaml.simple doc/config.yaml
- name: install python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
- name: install python requirements
run: pip install -r requirements.txt
- name: sync douban
if: env.USER_AGENT != null && env.DOUBAN_USER_ID != null && env.DOUBAN_DAY != null && env.NOTION_TOKEN != null && env.NOTION_BOOKS_DB != null && env.NOTION_MUSIC_DB != null && env.NOTION_MOVIE_DB != null && env.NOTION_GAME_DB != null
run: |
python3 run.py -m music -s all
python3 run.py -m book -s all
python3 run.py -m movie -s all
python3 run.py -m game -s allThe same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: sync_douban on: schedule: - cron: '0 0 * * *' workflow_dispatch: env: USER_AGENT: ${{ secrets.USER_AGENT }} USER_COOKIE: ${{ secrets.USER_COOKIE }} DOUBAN_USER_ID: ${{ secrets.DOUBAN_USER_ID }} DOUBAN_DAY: ${{ secrets.DOUBAN_DAY }} NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} NOTION_BOOKS_DB: ${{ secrets.NOTION_BOOKS_DB }} NOTION_MUSIC_DB: ${{ secrets.NOTION_MUSIC_DB }} NOTION_MOVIE_DB: ${{ secrets.NOTION_MOVIE_DB }} NOTION_GAME_DB: ${{ secrets.NOTION_GAME_DB }} jobs: sync_douban: timeout-minutes: 30 runs-on: macos-latest steps: - uses: actions/checkout@v3 - name: create config run: cp doc/config.yaml.simple doc/config.yaml - name: install python 3.9 uses: actions/setup-python@v4 with: python-version: '3.9' cache: 'pip' # caching pip dependencies - name: install python requirements run: pip install -r requirements.txt - name: sync douban if: env.USER_AGENT != null && env.DOUBAN_USER_ID != null && env.DOUBAN_DAY != null && env.NOTION_TOKEN != null && env.NOTION_BOOKS_DB != null && env.NOTION_MUSIC_DB != null && env.NOTION_MOVIE_DB != null && env.NOTION_GAME_DB != null run: | python3 run.py -m music -s all python3 run.py -m book -s all python3 run.py -m movie -s all python3 run.py -m game -s all
What changed
- 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.