deploy-to-hf-spaces.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. name: Deploy to HuggingFace Spaces
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. - main
  7. workflow_dispatch:
  8. jobs:
  9. check-secret:
  10. runs-on: ubuntu-latest
  11. outputs:
  12. token-set: ${{ steps.check-key.outputs.defined }}
  13. steps:
  14. - id: check-key
  15. env:
  16. HF_TOKEN: ${{ secrets.HF_TOKEN }}
  17. if: "${{ env.HF_TOKEN != '' }}"
  18. run: echo "defined=true" >> $GITHUB_OUTPUT
  19. deploy:
  20. runs-on: ubuntu-latest
  21. needs: [check-secret]
  22. if: needs.check-secret.outputs.token-set == 'true'
  23. env:
  24. HF_TOKEN: ${{ secrets.HF_TOKEN }}
  25. steps:
  26. - name: Checkout repository
  27. uses: actions/checkout@v4
  28. - name: Remove git history
  29. run: rm -rf .git
  30. - name: Prepend YAML front matter to README.md
  31. run: |
  32. echo "---" > temp_readme.md
  33. echo "title: Open WebUI" >> temp_readme.md
  34. echo "emoji: 🐳" >> temp_readme.md
  35. echo "colorFrom: purple" >> temp_readme.md
  36. echo "colorTo: gray" >> temp_readme.md
  37. echo "sdk: docker" >> temp_readme.md
  38. echo "app_port: 8080" >> temp_readme.md
  39. echo "---" >> temp_readme.md
  40. cat README.md >> temp_readme.md
  41. mv temp_readme.md README.md
  42. - name: Configure git
  43. run: |
  44. git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
  45. git config --global user.name "github-actions[bot]"
  46. - name: Set up Git and push to Space
  47. run: |
  48. git init --initial-branch=main
  49. git lfs track "*.ttf"
  50. rm demo.gif
  51. git add .
  52. git commit -m "GitHub deploy: ${{ github.sha }}"
  53. git push --force https://open-webui:${HF_TOKEN}@huggingface.co/spaces/open-webui/open-webui main