name: Test and Sync to Hugging Face hub on: push: branches: - main workflow_dispatch: jobs: test-and-sync: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 0 lfs: true - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install dependencies run: | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install pytest - name: Run tests env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: PYTHONPATH=. pytest --maxfail=1 --disable-warnings -q - name: Push to Hugging Face if: success() # only run if tests pass env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git config --global user.email "thameem022@gmail.com" git config --global user.name "Thameem022" git push --force https://mlops-group8:$HF_TOKEN@huggingface.co/spaces/mlops-group8/case-study-1 HEAD:main - name: Notify Slack (on success) if: success() uses: rtCamp/action-slack-notify@v2 env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_USERNAME: "GitHub Actions Bot" SLACK_ICON_EMOJI: ":hugging_face:" SLACK_COLOR: "#36a64f" SLACK_TITLE: "✅ Hugging Face Sync Successful" SLACK_MESSAGE: | Repo: ${{ github.repository }} Branch: ${{ github.ref }} Commit: ${{ github.sha }} Author: ${{ github.actor }} Message: ${{ github.event.head_commit.message }}