Skip to content
Latchkey

sync_douban workflow (Qliangw/notion_sync_data)

The sync_douban workflow from Qliangw/notion_sync_data, explained and optimized by Latchkey.

A

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 →
Source: Qliangw/notion_sync_data.github/workflows/sync_douban.yamlLicense MITView source

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

workflow (.yml)
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 all

The 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

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:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow