Commit
·
351bea0
1
Parent(s):
838b604
feat: enhance deployment workflows with GitHub Pages and Hugging Face integration
Browse files
.github/workflows/deploy-github-pages.yml
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Deploy to GitHub Pages
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main # Set to your default branch
|
| 7 |
+
workflow_dispatch: # Allow manual triggering of the workflow
|
| 8 |
+
|
| 9 |
+
permissions:
|
| 10 |
+
contents: read
|
| 11 |
+
pages: write
|
| 12 |
+
id-token: write
|
| 13 |
+
|
| 14 |
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
| 15 |
+
concurrency:
|
| 16 |
+
group: "pages"
|
| 17 |
+
cancel-in-progress: false
|
| 18 |
+
|
| 19 |
+
jobs:
|
| 20 |
+
build:
|
| 21 |
+
runs-on: ubuntu-latest
|
| 22 |
+
steps:
|
| 23 |
+
- name: Checkout code
|
| 24 |
+
uses: actions/checkout@v4
|
| 25 |
+
|
| 26 |
+
- name: Setup Bun
|
| 27 |
+
uses: oven-sh/setup-bun@v1
|
| 28 |
+
with:
|
| 29 |
+
bun-version: latest
|
| 30 |
+
|
| 31 |
+
- name: Install dependencies
|
| 32 |
+
run: bun install
|
| 33 |
+
|
| 34 |
+
- name: Build project for GitHub Pages
|
| 35 |
+
run: bun run build:github
|
| 36 |
+
|
| 37 |
+
- name: Setup Pages
|
| 38 |
+
uses: actions/configure-pages@v4
|
| 39 |
+
|
| 40 |
+
- name: Upload artifact
|
| 41 |
+
uses: actions/upload-pages-artifact@v3
|
| 42 |
+
with:
|
| 43 |
+
path: './dist'
|
| 44 |
+
|
| 45 |
+
deploy:
|
| 46 |
+
environment:
|
| 47 |
+
name: github-pages
|
| 48 |
+
url: ${{ steps.deployment.outputs.page_url }}
|
| 49 |
+
runs-on: ubuntu-latest
|
| 50 |
+
needs: build
|
| 51 |
+
steps:
|
| 52 |
+
- name: Deploy to GitHub Pages
|
| 53 |
+
id: deployment
|
| 54 |
+
uses: actions/deploy-pages@v4
|
.github/workflows/push-to-huggingface.yml
CHANGED
|
@@ -1,25 +1,49 @@
|
|
| 1 |
name: Push to Hugging Face Space
|
| 2 |
|
| 3 |
on:
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
branches:
|
| 6 |
-
-
|
| 7 |
workflow_dispatch: # Allow manual triggering of the workflow
|
| 8 |
|
| 9 |
jobs:
|
| 10 |
push-to-huggingface:
|
| 11 |
runs-on: ubuntu-latest
|
|
|
|
| 12 |
steps:
|
| 13 |
- name: Checkout code
|
| 14 |
-
uses: actions/checkout@
|
|
|
|
|
|
|
|
|
|
| 15 |
with:
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
- name: Configure Git
|
| 19 |
run: |
|
| 20 |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 21 |
git config --global user.name "GitHub Actions"
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
- name: Push to Hugging Face Space
|
| 24 |
env:
|
| 25 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
@@ -30,5 +54,5 @@ jobs:
|
|
| 30 |
# Set URL with token for authentication
|
| 31 |
git remote add space https://api-key:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE}
|
| 32 |
|
| 33 |
-
# Push to the
|
| 34 |
-
git push --force space
|
|
|
|
| 1 |
name: Push to Hugging Face Space
|
| 2 |
|
| 3 |
on:
|
| 4 |
+
# Trigger after GitHub Pages deployment succeeds
|
| 5 |
+
workflow_run:
|
| 6 |
+
workflows: ["Deploy to GitHub Pages"]
|
| 7 |
+
types:
|
| 8 |
+
- completed
|
| 9 |
branches:
|
| 10 |
+
- main
|
| 11 |
workflow_dispatch: # Allow manual triggering of the workflow
|
| 12 |
|
| 13 |
jobs:
|
| 14 |
push-to-huggingface:
|
| 15 |
runs-on: ubuntu-latest
|
| 16 |
+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
|
| 17 |
steps:
|
| 18 |
- name: Checkout code
|
| 19 |
+
uses: actions/checkout@v4
|
| 20 |
+
|
| 21 |
+
- name: Setup Bun
|
| 22 |
+
uses: oven-sh/setup-bun@v1
|
| 23 |
with:
|
| 24 |
+
bun-version: latest
|
| 25 |
+
|
| 26 |
+
- name: Install dependencies
|
| 27 |
+
run: bun install
|
| 28 |
+
|
| 29 |
+
- name: Build project
|
| 30 |
+
run: bun run build
|
| 31 |
|
| 32 |
+
- name: Configure Git for Hugging Face
|
| 33 |
run: |
|
| 34 |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 35 |
git config --global user.name "GitHub Actions"
|
| 36 |
|
| 37 |
+
- name: Create temporary branch for HF deployment
|
| 38 |
+
run: |
|
| 39 |
+
# Create and switch to a new branch with just the dist contents
|
| 40 |
+
git checkout --orphan temp-branch
|
| 41 |
+
git rm -rf .
|
| 42 |
+
cp -r dist/* .
|
| 43 |
+
touch .nojekyll
|
| 44 |
+
git add .
|
| 45 |
+
git commit -m "Deploy to Hugging Face Space"
|
| 46 |
+
|
| 47 |
- name: Push to Hugging Face Space
|
| 48 |
env:
|
| 49 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
|
|
| 54 |
# Set URL with token for authentication
|
| 55 |
git remote add space https://api-key:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE}
|
| 56 |
|
| 57 |
+
# Push to the main branch of the Space
|
| 58 |
+
git push --force space temp-branch:main
|
package.json
CHANGED
|
@@ -16,9 +16,10 @@
|
|
| 16 |
"lint": "eslint .",
|
| 17 |
"preview": "vite preview",
|
| 18 |
"predeploy": "bun run build",
|
| 19 |
-
"deploy": "bun run build && npx wrangler pages deploy dist",
|
| 20 |
-
"deploy:
|
| 21 |
-
"deploy:
|
|
|
|
| 22 |
},
|
| 23 |
"dependencies": {
|
| 24 |
"@clerk/clerk-react": "^5.23.0",
|
|
|
|
| 16 |
"lint": "eslint .",
|
| 17 |
"preview": "vite preview",
|
| 18 |
"predeploy": "bun run build",
|
| 19 |
+
"deploy:cloudflare": "bun run build && npx wrangler pages deploy dist",
|
| 20 |
+
"deploy:trigger-github": "gh workflow run deploy-github-pages.yml",
|
| 21 |
+
"deploy:trigger-huggingface": "gh workflow run push-to-huggingface.yml",
|
| 22 |
+
"deploy:all": "bun run deploy:cloudflare && bun run deploy:trigger-github && bun run deploy:trigger-huggingface"
|
| 23 |
},
|
| 24 |
"dependencies": {
|
| 25 |
"@clerk/clerk-react": "^5.23.0",
|