# workflow that syncs the main branch to the Hugging Face Hub (Huggingface Spaces) # only syncs if the build and lint is also fine # CREDIT: Adapted from Hugging Face, Inc. ## see https://huggingface.co/docs/hub/spaces-github-actions name: HGF Hub Sync (Main) # runs on pushes to the main branch and manually triggered workflows on: push: branches: [main] workflow_dispatch: permissions: contents: read # jobs to run jobs: # build job that installs dependencies and lints build: runs-on: ubuntu-latest steps: # checkout the repository - uses: actions/checkout@v3 # set up python 3.10 - name: Set up Python 3.10 uses: actions/setup-python@v3 with: python-version: "3.10" # install dependencies from requirements.txt - name: Install dependencies run: | python -m pip install --upgrade pip pip install pylint black if [ -f requirements.txt ]; then pip install -r requirements.txt; fi # lint and format all files with black (as defined in pyproject.toml) - name: Lint & Fix with Black run: black . # lint with pylint - name: Lint with Pylint run: pylint . # sync job sync-to-hub: runs-on: ubuntu-latest steps: # checkout the repository - uses: actions/checkout@v3 with: fetch-depth: 0 lfs: true # push to hub with huggingface token - name: Push to hub env: HF_TOKEN: ${{ secrets.HF_TOKEN }} # run git push run: git push https://LennardZuendorf:$HF_TOKEN@huggingface.co/spaces/LennardZuendorf/thesis main