File size: 1,953 Bytes
e7327da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: 部署到抱抱脸空间

on:
  push:
    branches:
      - dev
      - main
  workflow_dispatch:
  schedule:
    - cron: '0 20 * * *'  
jobs:
  check-secret:
    runs-on: ubuntu-latest
    outputs:
      token-set: ${{ steps.check-key.outputs.defined }}
    steps:
      - id: check-key
        env:
          HF_TOKEN: ${{ secrets.HF_TOKEN }}
        if: "${{ env.HF_TOKEN != '' }}"
        run: echo "defined=true" >> $GITHUB_OUTPUT

  deploy:
    runs-on: ubuntu-latest
    needs: [check-secret]
    if: needs.check-secret.outputs.token-set == 'true'
    env:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}
      HF_REPO: ${{ secrets.HF_REPO }}
      HF_USER: ${{ secrets.HF_USER }}
    steps:
      - name: 检出存储库
        uses: actions/checkout@v4
        with:
          lfs: true

      - name: 删除git历史记录
        run: rm -rf .git

      - name: 将YAML添加到README.md中
        run: |
          echo "---" > temp_readme.md
          echo "title: Open WebUI" >> temp_readme.md
          echo "emoji: 🐳" >> temp_readme.md
          echo "colorFrom: purple" >> temp_readme.md
          echo "colorTo: gray" >> temp_readme.md
          echo "sdk: docker" >> temp_readme.md
          echo "app_port: 8080" >> temp_readme.md
          echo "---" >> temp_readme.md
          cat README.md >> temp_readme.md
          mv temp_readme.md README.md

      - name: 配置git
        run: |
          git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git config --global user.name "github-actions[bot]"
      - name: 设置Git并推送到抱抱脸空间
        run: |
          git init --initial-branch=main
          git lfs install
          git lfs track "*.ttf"
          git lfs track "*.jpg"
          git add .
          git commit -m "GitHub deploy: ${{ github.sha }}"
          git push --force https://${HF_USER}:${HF_TOKEN}@huggingface.co/spaces/${HF_USER}/${HF_REPO} main