|
name: Mirror Community Pipeline |
|
|
|
on: |
|
|
|
push: |
|
branches: |
|
- main |
|
paths: |
|
- 'examples/community/**.py' |
|
|
|
|
|
tags: |
|
- '*' |
|
|
|
|
|
workflow_dispatch: |
|
inputs: |
|
ref: |
|
description: "Either 'main' or a tag ref" |
|
required: true |
|
default: 'main' |
|
|
|
jobs: |
|
mirror_community_pipeline: |
|
runs-on: ubuntu-latest |
|
steps: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Set checkout_ref and path_in_repo |
|
run: | |
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
|
if [ -z "${{ github.event.inputs.ref }}" ]; then |
|
echo "Error: Missing ref input" |
|
exit 1 |
|
elif [ "${{ github.event.inputs.ref }}" == "main" ]; then |
|
echo "CHECKOUT_REF=refs/heads/main" >> $GITHUB_ENV |
|
echo "PATH_IN_REPO=main" >> $GITHUB_ENV |
|
else |
|
echo "CHECKOUT_REF=refs/tags/${{ github.event.inputs.ref }}" >> $GITHUB_ENV |
|
echo "PATH_IN_REPO=${{ github.event.inputs.ref }}" >> $GITHUB_ENV |
|
fi |
|
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then |
|
echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV |
|
echo "PATH_IN_REPO=main" >> $GITHUB_ENV |
|
else |
|
# e.g. refs/tags/v0.28.1 -> v0.28.1 |
|
echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV |
|
echo "PATH_IN_REPO=$(echo ${{ github.ref }} | sed 's/^refs\/tags\///')" >> $GITHUB_ENV |
|
fi |
|
- name: Print env vars |
|
run: | |
|
echo "CHECKOUT_REF: ${{ env.CHECKOUT_REF }}" |
|
echo "PATH_IN_REPO: ${{ env.PATH_IN_REPO }}" |
|
- uses: actions/checkout@v3 |
|
with: |
|
ref: ${{ env.CHECKOUT_REF }} |
|
|
|
|
|
- name: Set up Python |
|
uses: actions/setup-python@v4 |
|
with: |
|
python-version: "3.10" |
|
- name: Install dependencies |
|
run: | |
|
python -m pip install --upgrade pip |
|
pip install --upgrade huggingface_hub |
|
|
|
|
|
- name: whoami |
|
run: huggingface-cli whoami |
|
env: |
|
HF_TOKEN: ${{ secrets.HF_TOKEN_MIRROR_COMMUNITY_PIPELINES }} |
|
|
|
|
|
|
|
- name: Mirror community pipeline to HF |
|
run: huggingface-cli upload diffusers/community-pipelines-mirror ./examples/community ${PATH_IN_REPO} --repo-type dataset |
|
env: |
|
PATH_IN_REPO: ${{ env.PATH_IN_REPO }} |
|
HF_TOKEN: ${{ secrets.HF_TOKEN_MIRROR_COMMUNITY_PIPELINES }} |