deploy-to-hf-spaces.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. with:
  29. lfs: true
  30. - name: Remove git history
  31. run: rm -rf .git
  32. - name: Prepend YAML front matter to README.md
  33. run: |
  34. echo "---" > temp_readme.md
  35. echo "title: Open WebUI" >> temp_readme.md
  36. echo "emoji: 🐳" >> temp_readme.md
  37. echo "colorFrom: purple" >> temp_readme.md
  38. echo "colorTo: gray" >> temp_readme.md
  39. echo "sdk: docker" >> temp_readme.md
  40. echo "app_port: 8080" >> temp_readme.md
  41. echo "---" >> temp_readme.md
  42. cat README.md >> temp_readme.md
  43. mv temp_readme.md README.md
  44. - name: Configure git
  45. run: |
  46. git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
  47. git config --global user.name "github-actions[bot]"
  48. - name: Set up Git and push to Space
  49. run: |
  50. git init --initial-branch=main
  51. git lfs install
  52. git lfs track "*.ttf"
  53. git lfs track "*.jpg"
  54. rm demo.gif
  55. git add .
  56. git commit -m "GitHub deploy: ${{ github.sha }}"
  57. git push --force https://open-webui:${HF_TOKEN}@huggingface.co/spaces/open-webui/open-webui main