AIenthusSP's picture
fix: deploy only after CI pipeline succeeds
999c76a
Raw History Blame Contribute Delete
2.08 kB
# GitHub Actions Deploy Pipeline
# Syncs repository to Hugging Face Spaces AFTER CI passes
name: Deploy to Hugging Face Spaces
on:
# Trigger after CI Pipeline completes successfully
workflow_run:
workflows: ["CI Pipeline"]
types:
- completed
branches: [main]
# Allow manual trigger
workflow_dispatch:
jobs:
sync-to-huggingface:
name: Sync to Hugging Face Spaces
runs-on: ubuntu-latest
# Only run if CI workflow succeeded (or if manually triggered)
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Prepare for HF Spaces
run: |
# Create HF-compatible README with Space metadata
cp README_HF.md README.md
# Ensure start script is executable
chmod +x start.sh
# Configure git
git config user.email "github-actions@github.com"
git config user.name "GitHub Actions"
# Commit changes if any
git add -A
git diff --staged --quiet || git commit -m "Prepare for HF Spaces deployment"
- name: Push to Hugging Face Hub
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
# Add HF remote
git remote add space https://user:$HF_TOKEN@huggingface.co/spaces/${{ secrets.HF_USERNAME }}/${{ secrets.HF_SPACE_NAME }} || true
# Force push to HF Spaces
git push space main:main --force
- name: Deployment Summary
run: |
echo "## 🚀 Deployment Complete!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ Synced to Hugging Face Spaces" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Space URL:** https://huggingface.co/spaces/${{ secrets.HF_USERNAME }}/${{ secrets.HF_SPACE_NAME }}" >> $GITHUB_STEP_SUMMARY