-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (67 loc) · 2.43 KB
/
build.yml
File metadata and controls
82 lines (67 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Deploy stlite to GitHub Pages
on:
push:
branches: [ master, main ]
paths:
- 'app.py'
- 'requirements.txt'
- 'build.sh'
workflow_dispatch: # Allow manual trigger
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write # Allow pushing to deploy branch
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # Need full history for branch operations
- name: Set up Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Make build script executable
run: chmod +x build.sh
- name: Run build script
run: ./build.sh
- name: Check for changes in index.html
id: check_changes
run: |
if git diff --quiet index.html; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "ℹ️ No changes to index.html"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "📝 Changes detected in index.html"
fi
- name: Create/update deploy-pages branch
if: steps.check_changes.outputs.changed == 'true'
run: |
# Create or switch to deploy-pages branch
git checkout -B deploy-pages
# Add only the files needed for GitHub Pages
git add index.html
git add app.py # Keep source for reference
git add build.sh # Keep build script
git add requirements.txt # Keep dependencies list
git add README.md # Keep documentation
# Commit the deployment
git commit -m "🚀 Deploy stlite to GitHub Pages
- Rebuilt index.html from app.py
- Triggered by master commit: ${{ github.sha }}
- Auto-generated deployment
Generated by GitHub Actions"
# Force push to deploy-pages branch
git push origin deploy-pages --force
echo "✅ Deployed to deploy-pages branch"
- name: Summary
run: |
if [ "${{ steps.check_changes.outputs.changed }}" == "true" ]; then
echo "✅ Deployment pushed to deploy-pages branch"
echo "🌐 Configure GitHub Pages to use deploy-pages branch"
echo "📝 Source commit: ${{ github.sha }}"
else
echo "ℹ️ No changes detected, skipping deployment"
fi