Ocelot-Social/.github/workflows/cache-verify.yml
resonic-user 66877e3e43 v
2025-06-16 12:16:57 +00:00

76 lines
2.3 KiB
YAML

name: CI Cache Verification
on:
push:
paths:
- '.github/workflows/cache-verify.yml'
workflow_dispatch:
jobs:
build-images:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: backend
context: ./backend
dockerfile: ./backend/Dockerfile
target: build
- name: webapp
context: ./webapp
dockerfile: ./webapp/Dockerfile
target: build
- name: neo4j
context: ./neo4j
dockerfile: ./neo4j/Dockerfile
target: community
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build ${{ matrix.name }} image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
target: ${{ matrix.target }}
push: false
outputs: type=docker,dest=/tmp/${{ matrix.name }}.tar
- name: Upload ${{ matrix.name }} image
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}-image
path: /tmp/${{ matrix.name }}.tar
verify-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- id: cache-key
env:
LOCK_HASH: ${{ hashFiles('backend/yarn.lock', 'webapp/yarn.lock') }}
run: echo "key=node-modules-${{ runner.os }}-${{ env.LOCK_HASH }}" >> $GITHUB_OUTPUT
- name: Show lockfile hashes (debug)
run: |
echo "backend/yarn.lock hash: ${{ hashFiles('backend/yarn.lock') }}"
echo "webapp/yarn.lock hash: ${{ hashFiles('webapp/yarn.lock') }}"
- name: Restore node_modules cache
id: restore-cache
uses: actions/cache@v4
with:
path: |
backend/node_modules
webapp/node_modules
key: ${{ steps.cache-key.outputs.key }}
restore-keys: |
node-modules-${{ runner.os }}-
node-modules-
- name: Show cache hit status
run: |
if [[ "${{ steps.restore-cache.outputs.cache-hit }}" == "true" ]]; then
echo "✅ Cache was hit!"
else
echo "❌ Cache was missed."
fi