Skip to content

Commit

Permalink
add build_hf_space
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Sep 25, 2024
1 parent 543edf4 commit 21840dc
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .github/workflows/build-hf-space.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build Hugging Face space

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: read

concurrency:
group: "hf_space"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Build Hugging Face space
shell: bash
run: |
if [ -z "$HF_TOKEN" ]; then
echo "HF_TOKEN is not set, skipping..."
else
cd scripts && ./build_hf_space.sh
fi
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules
/dist
/wasm
/esm
/models
/models
_tmp
1 change: 1 addition & 0 deletions scripts/_tmp_hf_space
Submodule _tmp_hf_space added at 6808fd
20 changes: 20 additions & 0 deletions scripts/build_hf_space.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

# clone
rm -rf _tmp_hf_space
git clone https://ngxson:${HF_TOKEN}@huggingface.co/spaces/ngxson/wllama --depth 1 _tmp_hf_space

# build
cd _tmp_hf_space
./build.sh

# push
git add -A
git commit -m "update"
git push

# clean up
cd ..
rm -rf _tmp_hf_space

0 comments on commit 21840dc

Please sign in to comment.