Skip to content

Commit e0fae6f

Browse files
Wauplinsayakpaul
andauthored
Mirror ./examples/community folder on HF (#8417)
* first draft * secret * tiktok * capital matters * dataset matter * don't be a prick * refact * only on main or tag * document with an example * Update destination dataset * link * allow manual trigger * better * lin --------- Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
1 parent ec1aded commit e0fae6f

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Fast tests for PRs
2+
3+
on:
4+
# Push changes on the main branch
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'examples/community/**.py'
10+
11+
# And on tag creation (e.g. `v0.28.1`)
12+
tags:
13+
- '*'
14+
15+
# Manual trigger with ref input
16+
workflow_dispatch:
17+
inputs:
18+
ref:
19+
description: "Either 'main' or a tag ref"
20+
required: true
21+
default: 'main'
22+
23+
jobs:
24+
mirror_community_pipeline:
25+
runs-on: ubuntu-latest
26+
steps:
27+
# Checkout to correct ref
28+
# If workflow dispatch
29+
# If ref is 'main', set:
30+
# CHECKOUT_REF=refs/heads/main
31+
# PATH_IN_REPO=main
32+
# Else it must be a tag. Set:
33+
# CHECKOUT_REF=refs/tags/{tag}
34+
# PATH_IN_REPO={tag}
35+
# If not workflow dispatch
36+
# If ref is 'refs/heads/main' => set 'main'
37+
# Else it must be a tag => set {tag}
38+
- name: Set checkout_ref and path_in_repo
39+
run: |
40+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
41+
if [ -z "${{ github.event.inputs.ref }}" ]; then
42+
echo "Error: Missing ref input"
43+
exit 1
44+
elif [ "${{ github.event.inputs.ref }}" == "main" ]; then
45+
echo "CHECKOUT_REF=refs/heads/main" >> $GITHUB_ENV
46+
echo "PATH_IN_REPO=main" >> $GITHUB_ENV
47+
else
48+
echo "CHECKOUT_REF=refs/tags/${{ github.event.inputs.ref }}" >> $GITHUB_ENV
49+
echo "PATH_IN_REPO=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
50+
fi
51+
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
52+
echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV
53+
echo "PATH_IN_REPO=main" >> $GITHUB_ENV
54+
else
55+
# e.g. refs/tags/v0.28.1 -> v0.28.1
56+
echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV
57+
echo "PATH_IN_REPO=${${{ github.ref }}#refs/tags/}" >> $GITHUB_ENV
58+
fi
59+
- uses: actions/checkout@v3
60+
with:
61+
ref: ${{ env.CHECKOUT_REF }}
62+
63+
# Setup + install dependencies
64+
- name: Set up Python
65+
uses: actions/setup-python@v4
66+
with:
67+
python-version: "3.10"
68+
- name: Install dependencies
69+
run: |
70+
python -m pip install uv
71+
uv pip install --upgrade huggingface_hub
72+
73+
# Check secret is set
74+
- name: whoami
75+
run: huggingface-cli whoami
76+
env:
77+
HF_TOKEN: ${{ secrets.HF_TOKEN_MIRROR_COMMUNITY_PIPELINES }}
78+
79+
# Push to HF! (under subfolder based on checkout ref)
80+
# https://huggingface.co/datasets/diffusers/community-pipelines-mirror
81+
- name: Mirror community pipeline to HF
82+
run: huggingface-cli upload diffusers/community-pipelines-mirror ./examples/community ${PATH_IN_REPO} --repo-type dataset
83+
env:
84+
PATH_IN_REPO: ${{ env.PATH_IN_REPO }}
85+
HF_TOKEN: ${{ secrets.HF_TOKEN_MIRROR_COMMUNITY_PIPELINES }}

0 commit comments

Comments
 (0)