Skip to content
Latchkey

Sync to Hugging Face hub workflow (xiaosu-zhu/McQuic)

The Sync to Hugging Face hub workflow from xiaosu-zhu/McQuic, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: xiaosu-zhu/McQuic.github/workflows/auto-deploy-huggingface.ymlLicense Apache-2.0View source

What it does

This is the Sync to Hugging Face hub workflow from the xiaosu-zhu/McQuic repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Sync to Hugging Face hub
on:
  workflow_run:
    workflows: [Bump version]
    types:
      - completed

jobs:
  sync-to-hub:
    runs-on: ubuntu-latest
    env:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}
    steps:
      - name: Delay 300 seconds (wait for pypi package online)
        run: sleep 300s
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Clone HF
        run: |
          git clone https://xiaosu-zhu:$HF_TOKEN@huggingface.co/spaces/xiaosu-zhu/McQuic.git hfSpace
          cp mcquic/service/stCompressService.py hfSpace/
          python ci/pre_commit/update_hf_space_require.py mcquic/__init__.py hfSpace/requirements.txt
          cd hfSpace
          git add .
          git config --global user.email "xiaosu.zhu@outlook.com"
          git config --global user.name "Xiaosu Zhu"
          git commit -m "Auto deploy"
          git push

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Sync to Hugging Face hub
on:
  workflow_run:
    workflows: [Bump version]
    types:
      - completed
 
jobs:
  sync-to-hub:
    timeout-minutes: 30
    runs-on: latchkey-small
    env:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}
    steps:
      - name: Delay 300 seconds (wait for pypi package online)
        run: sleep 300s
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Clone HF
        run: |
          git clone https://xiaosu-zhu:$HF_TOKEN@huggingface.co/spaces/xiaosu-zhu/McQuic.git hfSpace
          cp mcquic/service/stCompressService.py hfSpace/
          python ci/pre_commit/update_hf_space_require.py mcquic/__init__.py hfSpace/requirements.txt
          cd hfSpace
          git add .
          git config --global user.email "xiaosu.zhu@outlook.com"
          git config --global user.name "Xiaosu Zhu"
          git commit -m "Auto deploy"
          git push
 

What changed

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