console/.github/actions/setup/action.yml
renovate[bot] 5f740b315f
chore(deps): update pnpm/action-setup action to v3 (#3961)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-12 09:25:59 +02:00

90 lines
2.7 KiB
YAML

# Note: This is a composite GitHub Action.
# Docs: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
name: setup
description: Hive CI environment setup
inputs:
codegen:
description: Should run GraphQL Codegen?
default: 'true'
installDependencies:
description: Should run pnpm install?
default: 'true'
workingDirectory:
description: Working dir
default: ${{ github.workspace }}
actor:
description: Name of the workflow that called this action
required: true
type: string
cacheNext:
description: Should cache Next?
default: 'true'
cacheTurbo:
description: Should cache Turbo?
default: 'true'
runs:
using: 'composite'
steps:
- name: check pnpm version
shell: bash
id: pnpm
run: |
PNPM_VERSION=$(cat package.json | jq -r '.packageManager' | awk -F@ '{print $2}')
PNPM_VERSION=${PNPM_VERSION:-8}
echo "Using PNPM version $PNPM_VERSION"
echo "version=$PNPM_VERSION" >> $GITHUB_OUTPUT
if [ ${{ inputs.installDependencies }} = true ]; then
echo "cache=pnpm" >> $GITHUB_OUTPUT
else
echo "cache=" >> "$GITHUB_ENV"
fi
- name: install pnpm
uses: pnpm/action-setup@v3.0.0
with:
version: ${{ steps.pnpm.outputs.version }}
- name: install nodejs
uses: actions/setup-node@v4.0.2
with:
node-version-file: .node-version
cache: ${{ steps.pnpm.outputs.cache }}
- name: Cache Turbo
uses: actions/cache@v4
if: ${{ inputs.cacheNext == 'true' }}
with:
path: node_modules/.cache/turbo
key: turbo-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ inputs.actor }}-${{ github.sha }}
restore-keys: |
turbo-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ inputs.actor }}-
turbo-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-
- uses: actions/cache@v4
name: Cache Next.js
if: ${{ inputs.cacheNext == 'true' }}
with:
path: |
packages/web/app/.next/cache
packages/web/docs/.next/cache
key:
nextjs-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ inputs.actor }}-${{ github.sha }}
restore-keys: |
nextjs-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ inputs.actor }}-
nextjs-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: pnpm install
shell: bash
if: ${{ inputs.installDependencies == 'true' }}
working-directory: ${{ inputs.workingDirectory }}
run: pnpm install --frozen-lockfile
- name: generate graphql types
if: ${{ inputs.codegen == 'true' }}
shell: bash
working-directory: ${{ inputs.workingDirectory }}
run: pnpm graphql:generate