Create .github/workflows/sync-from-hf-space.yml
Browse files
.github/workflows/sync-from-hf-space.yml
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync from Hugging Face Space to GitHub
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
schedule:
|
| 6 |
+
- cron: '0 0 * * *' # This will run daily at midnight; adjust as needed
|
| 7 |
+
push:
|
| 8 |
+
branches:
|
| 9 |
+
- main # Change this to your default branch if different
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
sync:
|
| 13 |
+
runs-on: ubuntu-latest
|
| 14 |
+
|
| 15 |
+
steps:
|
| 16 |
+
- name: Checkout GitHub repository
|
| 17 |
+
uses: actions/checkout@v2
|
| 18 |
+
|
| 19 |
+
- name: Fetch code from Hugging Face Space
|
| 20 |
+
run: |
|
| 21 |
+
git clone https://huggingface.co/spaces/jdbolter/Langbot hf-space
|
| 22 |
+
cd hf-space
|
| 23 |
+
git fetch
|
| 24 |
+
git checkout main # Adjust if using a different branch
|
| 25 |
+
|
| 26 |
+
- name: Configure Git
|
| 27 |
+
run: |
|
| 28 |
+
git config --global user.email "jdbolter@me.com"
|
| 29 |
+
git config --global user.name "jdbolter"
|
| 30 |
+
|
| 31 |
+
- name: Sync Hugging Face Space code to GitHub
|
| 32 |
+
run: |
|
| 33 |
+
cd hf-space
|
| 34 |
+
if git remote get-url origin > /dev/null 2>&1; then
|
| 35 |
+
git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/jdbolter/HFbot.git
|
| 36 |
+
else
|
| 37 |
+
git remote add origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/jdbolter/HFbot.git
|
| 38 |
+
fi
|
| 39 |
+
git push origin main --force # Adjust the branch name if necessary
|
| 40 |
+
|
| 41 |
+
- name: Check for changes and commit if any
|
| 42 |
+
run: |
|
| 43 |
+
cd hf-space
|
| 44 |
+
git add .
|
| 45 |
+
if git diff-index --quiet HEAD; then
|
| 46 |
+
echo "No changes to commit"
|
| 47 |
+
else
|
| 48 |
+
git commit -m "Sync from Hugging Face Space"
|
| 49 |
+
git push origin main # Adjust the branch name if necessary
|
| 50 |
+
fi
|
| 51 |
+
|
| 52 |
+
env:
|
| 53 |
+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|