diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..922e5f5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,48 @@ +name: Sync to Hugging Face hub +on: + repository_dispatch: + push: + branches: + - main + + # to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + sync-to-hub: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + lfs: true + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: sync to huggingface + env: + HF_TOKEN: ${{ secrets.HF_TOKEN }} + HF_USERNAME: ${{ secrets.HF_USERNAME }} + SPACE_NAME: ${{ secrets.SPACE_NAME }} + run: | + npm i + npm run build + git clone https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME --depth=1 target + find target -maxdepth 1 -regextype posix-egrep ! -iregex 'target/?(README.md|.git|.gitignore)' | xargs rm -rf + rm -rf target/* + mv out/* target + cd target + git config user.name $HF_USERNAME + git config user.email $HF_USERNAME@huggingface.co + git add -A + git commit -am "auto deploy" + git push origin main -f + + - name: Push to gh_pages + uses: s0/git-publish-subdir-action@develop + env: + REPO: self + BRANCH: gh_pages # The branch name where you want to push the assets + FOLDER: target # The directory where your assets are generated + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token + MESSAGE: "Build: ({sha}) {msg}" # The commit message diff --git a/.github/workflows/huggingface.yml b/.github/workflows/huggingface.yml deleted file mode 100644 index b21a8c5..0000000 --- a/.github/workflows/huggingface.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Sync to Hugging Face hub -on: - workflow_run: - workflows: ["Build Docker Image"] - types: - - completed - push: - branches: - - main - - # to run this workflow manually from the Actions tab - workflow_dispatch: - -#find . -maxdepth 1 -regextype posix-egrep ! -iregex './(out|.github|.gitignore|.git)' | xargs rm -rf - -jobs: - sync-to-hub: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - lfs: true - - name: Push to hub - env: - HF_TOKEN: ${{ secrets.HF_TOKEN }} - HF_USERNAME: ${{ secrets.HF_USERNAME }} - SPACE_NAME: ${{ secrets.SPACE_NAME }} - run: | - npm i - npm run build - git clone https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main - mv out/* $SPACE_NAME - cd $SPACE_NAME - git add -A - git commit -am "auto deploy" - git push origin main -f