openpencil/.github/actions/setup-bun/action.yml

68 lines
2 KiB
YAML

name: Setup Bun workspace
description: Check out-independent Bun setup, cache, optional LFS pull, and install.
inputs:
install-args:
description: Arguments passed to bun install.
required: false
default: --frozen-lockfile
lfs:
description: Pull Git LFS files before installing dependencies.
required: false
default: 'false'
lfs-include:
description: Comma-separated `git lfs pull --include` patterns. Empty pulls every LFS object.
required: false
default: ''
cache-save:
description: Save the dependency cache; set false for other jobs sharing the same cache key.
required: false
default: 'true'
cache-scope:
description: Separate dependency caches for independently running workflow groups.
required: false
default: workspace
runs:
using: composite
steps:
- name: Pull LFS files
if: inputs.lfs == 'true'
shell: bash
env:
LFS_INCLUDE: ${{ inputs.lfs-include }}
run: |
git lfs install --force
if [ -n "$LFS_INCLUDE" ]; then
git lfs pull --include="$LFS_INCLUDE"
else
git lfs pull
head -c 4 tests/fixtures/material3.fig | xxd
fi
head -c 4 tests/fixtures/gold-preview.fig | xxd
- uses: oven-sh/setup-bun@v2
with:
# Avoid a second cache/upload lifecycle for the small Bun executable.
no-cache: true
- uses: actions/cache/restore@v6
id: dependencies
with:
path: ~/.bun/install/cache
key: bun-${{ inputs.cache-scope }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('bun.lock') }}
restore-keys: bun-${{ inputs.cache-scope }}-${{ runner.os }}-${{ runner.arch }}-
- name: Install dependencies
shell: bash
run: bun install ${{ inputs.install-args }}
- name: Save dependency cache
if: inputs.cache-save == 'true' && steps.dependencies.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ~/.bun/install/cache
key: ${{ steps.dependencies.outputs.cache-primary-key }}