Files
2026-03-11 00:50:50 +09:00

69 lines
2.4 KiB
YAML

name: Warmup Cache
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
inputs:
is_force:
description: "是否强制重新构建缓存"
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
# 预热 Go 依赖缓存
go-cache:
uses: ./.github/workflows/go-cache.yaml
build-web:
needs: go-cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# First, check if web build cache exists (restore-only);
# if hit, we'll skip the rest of the job
- name: Restore cache of built web (src/webapp/build)
id: cache_web_build
uses: actions/cache/restore@v4
with:
path: |
src/webapp/build
key: web-build-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.node-version', 'src/webapp/yarn.lock', 'src/webapp/package.json', 'src/webapp/tsconfig.json', 'src/webapp/src/**', 'src/webapp/public/**') }}
- name: Web build cache hit — end early
if: ${{ steps.cache_web_build.outputs.cache-hit == 'true' && github.event.inputs.is_force != 'true' }}
run: echo "Web build cache hit; skipping setup, caching and build steps."
- uses: actions/setup-node@v4
if: ${{ steps.cache_web_build.outputs.cache-hit != 'true' && github.event.inputs.is_force != 'true' }}
with:
node-version-file: '.node-version'
cache: yarn
cache-dependency-path: 'src/webapp/yarn.lock'
- uses: actions/setup-go@v6
if: ${{ steps.cache_web_build.outputs.cache-hit != 'true' && github.event.inputs.is_force != 'true' }}
with:
go-version: '1.25'
cache: true
cache-dependency-path: '**/go.sum'
- name: Build Web Page
if: ${{ steps.cache_web_build.outputs.cache-hit != 'true' || github.event.inputs.is_force == 'true' }}
run: make build-web
- name: Save built web to cache (src/webapp/build)
if: ${{ steps.cache_web_build.outputs.cache-hit != 'true' && github.event.inputs.is_force != 'true' }}
uses: actions/cache/save@v4
with:
path: |
src/webapp/build
key: web-build-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.node-version', 'src/webapp/yarn.lock', 'src/webapp/package.json', 'src/webapp/tsconfig.json', 'src/webapp/src/**', 'src/webapp/public/**') }}