File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed
Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 1+ name : Build and Deploy to GitHub Pages
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ branches :
7+ - main
8+
9+ jobs :
10+ build-and-deploy :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+
15+ - name : Set up Node.js
16+ uses : actions/setup-node@v4
17+ with :
18+ node-version : 20
19+
20+ - name : Install pnpm
21+ uses : pnpm/action-setup@v2
22+ with :
23+ version : 8
24+
25+ - name : Install dependencies
26+ run : pnpm install
27+
28+ - name : Build app
29+ run : pnpm build
30+
31+ - name : Deploy to GitHub Pages
32+ run : pnpm run deploy
33+ env :
34+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1010 runs-on : ubuntu-latest
1111 steps :
1212 - uses : actions/checkout@v4
13+ with :
14+ fetch-depth : 0 # fetch all branches for later checkout
1315
1416 - name : Set up Node.js
1517 uses : actions/setup-node@v4
@@ -24,10 +26,21 @@ jobs:
2426 YOUTUBE_API_KEY : ${{ secrets.YOUTUBE_API_KEY }}
2527 run : node fetch-youtube.js
2628
27- - name : Commit and push
29+ - name : Commit and push to main
2830 run : |
2931 git config user.name github-actions
3032 git config user.email github-actions@github.com
3133 git add public/youtube-data.json
3234 git commit -m "Update YouTube data [skip ci]" || echo "No changes to commit"
33- git push
35+ git push origin main
36+
37+ - name : Update gh-pages branch with new data
38+ run : |
39+ git fetch origin gh-pages:gh-pages || echo "No gh-pages branch yet"
40+ git checkout gh-pages || echo "No gh-pages branch to update"
41+ cp public/youtube-data.json public/youtube-data.json
42+ git add public/youtube-data.json
43+ git commit -m "Update YouTube data [skip ci]" || echo "No changes to commit"
44+ git push origin gh-pages || echo "No gh-pages branch to push"
45+ git checkout main
46+ continue-on-error : true
You can’t perform that action at this time.
0 commit comments