name: Update Hub repositories

on:
  push:
    branches:
      - main

jobs:
  update-hub-repositories:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.8"
      - name: Set up default Git config
        run: |
          git config --global user.name evaluate-bot
          git config --global user.email leandro@huggingface.co
      - name: Install dependencies
        working-directory: ./.github/hub
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
      - name: Update Hub repositories
        working-directory: ./.github/hub
        run: |
          export HF_TOKEN=${{ secrets.HF_HUB_TOKEN }}
          export EVALUATE_LIB_PATH=$GITHUB_WORKSPACE
          export GIT_HASH=$GITHUB_SHA
          export GIT_LFS_SKIP_SMUDGE=1
          python push_evaluations_to_hub.py