changed HF action to always rebuild docker image

This commit is contained in:
Gamosoft 2025-12-08 11:12:55 +01:00
parent ebc40c7c07
commit b9982a3a53
1 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
name: Restart Hugging Face Space name: Rebuild Hugging Face Space
on: on:
# Can be called from other workflows # Can be called from other workflows
@ -10,12 +10,12 @@ on:
- cron: '0 0 * * *' # Daily at midnight UTC - cron: '0 0 * * *' # Daily at midnight UTC
jobs: jobs:
restart-space: rebuild-space:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Restart Hugging Face Space - name: Rebuild Hugging Face Space
run: | run: |
echo "Triggering HF Space restart to pull latest image..." echo "Triggering HF Space factory rebuild to pull latest image..."
if [ -z "${{ vars.HF_SPACE_ID }}" ]; then if [ -z "${{ vars.HF_SPACE_ID }}" ]; then
echo "::warning::HF_SPACE_ID variable not set. Skipping HF restart." echo "::warning::HF_SPACE_ID variable not set. Skipping HF restart."
@ -28,7 +28,7 @@ jobs:
fi fi
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
"https://huggingface.co/api/spaces/${{ vars.HF_SPACE_ID }}/restart" \ "https://huggingface.co/api/spaces/${{ vars.HF_SPACE_ID }}/restart?factory=true" \
-H "Authorization: Bearer ${{ secrets.HF_TOKEN }}" \ -H "Authorization: Bearer ${{ secrets.HF_TOKEN }}" \
-H "Content-Type: application/json") -H "Content-Type: application/json")
@ -36,10 +36,10 @@ jobs:
BODY=$(echo "$RESPONSE" | sed '$d') BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
echo "✅ HF Space restart triggered successfully!" echo "✅ HF Space factory rebuild triggered successfully!"
echo "Space: ${{ vars.HF_SPACE_ID }}" echo "Space: ${{ vars.HF_SPACE_ID }}"
else else
echo "::warning::HF Space restart failed (HTTP $HTTP_CODE)" echo "::warning::HF Space rebuild failed (HTTP $HTTP_CODE)"
echo "Response: $BODY" echo "Response: $BODY"
echo "Space may not exist or token may be invalid." echo "Space may not exist or token may be invalid."
fi fi