Archisman Karmakar
commited on
Create deploy_to_HF_space.yml
Browse files
.github/workflows/deploy_to_HF_space.yml
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Deploy to Hugging Face Spaces
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main
|
| 7 |
+
workflow_dispatch:
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
deploy-to-hf:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
|
| 13 |
+
steps:
|
| 14 |
+
- name: Check out repository with LFS support
|
| 15 |
+
uses: actions/checkout@v3
|
| 16 |
+
with:
|
| 17 |
+
fetch-depth: 0
|
| 18 |
+
lfs: true
|
| 19 |
+
|
| 20 |
+
- name: Set up Python 3.12
|
| 21 |
+
uses: actions/setup-python@v4
|
| 22 |
+
with:
|
| 23 |
+
python-version: "3.12"
|
| 24 |
+
|
| 25 |
+
- name: Install dependencies
|
| 26 |
+
run: |
|
| 27 |
+
echo "Python version:"
|
| 28 |
+
python --version
|
| 29 |
+
# Install from requirements.txt if available
|
| 30 |
+
if [ -f requirements.txt ]; then
|
| 31 |
+
echo "Installing from requirements.txt"
|
| 32 |
+
pip install -r requirements.txt
|
| 33 |
+
fi
|
| 34 |
+
# Optionally install the package using pyproject.toml if needed
|
| 35 |
+
if [ -f pyproject.toml ]; then
|
| 36 |
+
echo "Installing package via pyproject.toml"
|
| 37 |
+
pip install .
|
| 38 |
+
fi
|
| 39 |
+
|
| 40 |
+
- name: Install Hugging Face CLI
|
| 41 |
+
run: pip install huggingface_hub
|
| 42 |
+
|
| 43 |
+
- name: Configure Git
|
| 44 |
+
run: |
|
| 45 |
+
git config --global user.email "actions@github.com"
|
| 46 |
+
git config --global user.name "GitHub Actions"
|
| 47 |
+
|
| 48 |
+
- name: Clone Hugging Face Space
|
| 49 |
+
run: huggingface-cli repo clone \
|
| 50 |
+
YOUR_HF_USERNAME/SPACE_NAME \
|
| 51 |
+
--token "${{ secrets.HF_READ_WRITE_TOKEN }}" \
|
| 52 |
+
--branch main \
|
| 53 |
+
hf-space
|
| 54 |
+
|
| 55 |
+
- name: Copy repository files to HF Space
|
| 56 |
+
run: |
|
| 57 |
+
# Remove the .git folder so we can reinitialize a clean git repository
|
| 58 |
+
rm -rf hf-space/.git
|
| 59 |
+
cp -R . hf-space
|
| 60 |
+
|
| 61 |
+
- name: Commit and push to Hugging Face
|
| 62 |
+
run: |
|
| 63 |
+
cd hf-space
|
| 64 |
+
git init
|
| 65 |
+
git remote add origin https://huggingface.co/spaces/tachygraphy-microtrext-norm-org/Tachygraphy-Microtext-Analysis-and-Normalization-ArchismanCoder
|
| 66 |
+
git checkout -b main
|
| 67 |
+
git add .
|
| 68 |
+
git commit -m "Update deployment via GitHub Actions"
|
| 69 |
+
git push -f origin main
|
| 70 |
+
echo "Deployment to Hugging Face Spaces completed!"
|