Skip to content

Commit e735a28

Browse files
committed
cacher
1 parent 4e9ca6a commit e735a28

3 files changed

Lines changed: 88 additions & 2 deletions

File tree

.github/workflows/generate-cache.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,22 @@ jobs:
3535
steps:
3636
- name: Checkout this repository
3737
uses: actions/checkout@v4
38+
39+
- name: Pull latest cache from cache-data branch
40+
run: |
41+
git fetch origin cache-data || true
42+
git checkout cache-data -- . || true
43+
mkdir -p trease-backend/cache/images trease-backend/cache/video
44+
# Move pulled cache directly into trease-backend/cache
45+
if [ -d cache ]; then
46+
cp -r cache/* trease-backend/cache/ 2>/dev/null || true
47+
rm -rf cache
48+
fi
49+
continue-on-error: true
3850

39-
- name: Clone trease-backend repository
51+
- name: Clone trease-backend repository (with submodules)
4052
run: |
41-
git clone https://github.com/Trease-Focus/trease-backend.git trease-backend --depth 1
53+
git clone --recurse-submodules https://github.com/Trease-Focus/trease-backend.git trease-backend --depth 1
4254
4355
- name: Install ffmpeg
4456
run: |
@@ -91,6 +103,20 @@ jobs:
91103
with:
92104
path: '_site'
93105

106+
- name: Push cache to cache-data branch
107+
run: |
108+
git config --global user.name "github-actions"
109+
git config --global user.email "github-actions@github.com"
110+
git fetch origin cache-data || true
111+
git checkout -B cache-data origin/cache-data || git checkout --orphan cache-data
112+
rm -rf *
113+
cp -r _site/* .
114+
git add .
115+
git commit -m "Update cache $(date -u)" || echo "No changes to commit"
116+
git push origin cache-data
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
94120
deploy:
95121
environment:
96122
name: github-pages
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Manual Generate Cache (No Pull)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout this repository
11+
uses: actions/checkout@v4
12+
- name: Clone trease-backend repository
13+
run: |
14+
git clone https://github.com/Trease-Focus/trease-backend.git trease-backend --depth 1
15+
- name: Install ffmpeg
16+
run: |
17+
sudo apt-get update
18+
sudo apt-get install -y ffmpeg
19+
- name: Setup Bun
20+
uses: oven-sh/setup-bun@v2
21+
with:
22+
bun-version: latest
23+
- name: Install dependencies
24+
working-directory: trease-backend
25+
run: bun install
26+
- name: Generate Image Cache
27+
working-directory: trease-backend
28+
run: bun run cache-gen/generate_image_cache.ts
29+
- name: Generate Video Cache
30+
working-directory: trease-backend
31+
run: bun run cache-gen/generate_video_cache.ts
32+
- name: Generate Data Cache
33+
working-directory: trease-backend
34+
run: bun run cache-gen/generate_entity_data.ts
35+
- name: Prepare output for GitHub Pages
36+
run: |
37+
mkdir -p _site
38+
cp -r trease-backend/cache/* _site/ 2>/dev/null
39+
if [ ! -f _site/index.html ]; then
40+
echo '<!DOCTYPE html><html><head><title>Image Cache</title></head><body><h1>Image Cache Generated</h1><p>Last updated: '"$(date -u)"'</p></body></html>' > _site/index.html
41+
fi
42+
- name: Copy Additional Assets
43+
run: |
44+
cp cache/images/* _site/images 2>/dev/null || true
45+
cp cache/video/* _site/video 2>/dev/null || true
46+
- name: Setup Pages
47+
uses: actions/configure-pages@v4
48+
- name: Upload artifact
49+
uses: actions/upload-pages-artifact@v3
50+
with:
51+
path: '_site'
52+
deploy:
53+
environment:
54+
name: github-pages
55+
runs-on: ubuntu-latest
56+
needs: build
57+
steps:
58+
- name: Deploy to GitHub Pages
59+
id: deployment
60+
uses: actions/deploy-pages@v4

cache/images/weathered_grid.png

-48.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)