Skip to content

Commit ba4afbe

Browse files
committed
add ci
1 parent a3e44e6 commit ba4afbe

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Generate Image Cache and Deploy to GitHub Pages
2+
3+
on:
4+
# Run on a schedule (every day at midnight UTC)
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
# Allow manual trigger
9+
workflow_dispatch:
10+
11+
# Also run on push to main branch
12+
push:
13+
branches:
14+
- main
15+
16+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
17+
permissions:
18+
contents: read
19+
pages: write
20+
id-token: write
21+
22+
# Allow only one concurrent deployment
23+
concurrency:
24+
group: "pages"
25+
cancel-in-progress: false
26+
27+
jobs:
28+
build:
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- name: Checkout this repository
33+
uses: actions/checkout@v4
34+
35+
- name: Clone trease-backend repository
36+
run: |
37+
git clone https://github.com/Trease-Focus/trease-backend.git trease-backend --depth 1
38+
39+
- name: Install ffmpeg
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y ffmpeg
43+
44+
- name: Setup Bun
45+
uses: oven-sh/setup-bun@v2
46+
with:
47+
bun-version: latest
48+
49+
- name: Install dependencies
50+
working-directory: trease-backend
51+
run: bun install
52+
53+
- name: Run cache generation script
54+
working-directory: trease-backend
55+
run: bun run cache-gen/generate_image_cache.ts
56+
57+
- name: Prepare output for GitHub Pages
58+
run: |
59+
mkdir -p _site
60+
# Copy generated cache files to _site directory
61+
# Adjust this path based on where the script outputs files
62+
cp -r trease-backend/cache-gen/cache/* _site/ 2>/dev/null
63+
# Create an index.html if one doesn't exist
64+
if [ ! -f _site/index.html ]; then
65+
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
66+
fi
67+
68+
- name: Setup Pages
69+
uses: actions/configure-pages@v4
70+
71+
- name: Upload artifact
72+
uses: actions/upload-pages-artifact@v3
73+
with:
74+
path: '_site'
75+
76+
deploy:
77+
environment:
78+
name: github-pages
79+
url: ${{ steps.deployment.outputs.page_url }}
80+
runs-on: ubuntu-latest
81+
needs: build
82+
83+
steps:
84+
- name: Deploy to GitHub Pages
85+
id: deployment
86+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)