|
| 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 |
0 commit comments