Spaces:
Configuration error
Configuration error
| name: Deploy backend to HuggingFace Space | |
| on: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: [completed] | |
| branches: [main] | |
| workflow_dispatch: | |
| concurrency: | |
| group: deploy-backend | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| push-to-space: | |
| name: Push main to HF Space | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| if: >- | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.head_branch == 'main') | |
| env: | |
| HF_USERNAME: apoorvrajdev | |
| HF_SPACE: image-captioning-api | |
| steps: | |
| - name: Checkout full history | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure git identity | |
| run: | | |
| git config user.name "apoorvrajdev" | |
| git config user.email "apoorvrajmgr@gmail.com" | |
| - name: Push to HuggingFace Space | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| if [ -z "${HF_TOKEN}" ]; then | |
| echo "::error::HF_TOKEN secret is not set. Add it under repo Settings → Secrets and variables → Actions." | |
| exit 1 | |
| fi | |
| git remote add space "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE}" | |
| git push space HEAD:main | |