LIBRE / .github /workflows /deploy.yml
RyZ
chore: specify kaggle target username and slug in deployment flow
ce458f9
Raw
History Blame Contribute Delete
2.12 kB
name: CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: uv sync --extra dev
- name: Run pytest
run: uv run pytest
deploy-api:
name: Deploy API to Hugging Face Spaces
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Push to Hugging Face Spaces
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }} # e.g. username/space-name
run: |
git remote add hf https://user:$HF_TOKEN@huggingface.co/spaces/$HF_SPACE_NAME
git push --force hf main
deploy-consumer:
name: Deploy Consumer to Kaggle
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build Kaggle Bundle
env:
KAGGLE_USERNAME: benedictusryugunawan
KAGGLE_SLUG: libre
run: python scripts/build_kaggle_deploy.py
- name: Create Kaggle API Config
env:
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
run: |
mkdir -p ~/.kaggle
echo "{\"username\":\"benedictusryugunawan\",\"key\":\"$KAGGLE_KEY\"}" > ~/.kaggle/kaggle.json
chmod 600 ~/.kaggle/kaggle.json
- name: Push Kernel to Kaggle
run: |
pip install kaggle
kaggle kernels push -p kaggle_deploy/