Skip to content

Commit 834266d

Browse files
update github pages publish and youtube fetch workflows
1 parent bb68f75 commit 834266d

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 }}

.github/workflows/fetch-youtube.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
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

0 commit comments

Comments
 (0)