Skip to content

Commit

Permalink
ci: create reusable action for Node.js and pnpm setup with optimized …
Browse files Browse the repository at this point in the history
…dependency caching
  • Loading branch information
justin-lau committed Jan 10, 2025
1 parent 4449898 commit bbdbbae
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 150 deletions.
27 changes: 27 additions & 0 deletions .github/actions/setup-node-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Setup Node.js and pnpm'

inputs:
node-version:
type: string
default: '22'
description: 'The version of Node.js to use'

pnpm-version:
type: string
default: '9'
description: 'The version of pnpm to use'

runs:
using: "composite"
steps:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ inputs.pnpm-version }}
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: 'pnpm'
40 changes: 3 additions & 37 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,19 @@ on:
types: [opened, synchronize, reopened]

env:
NODE_VERSION: '22'
PNPM_VERSION: '9'
TEST_EAS_PRIVATE_KEY: ${{ secrets.TEST_EAS_PRIVATE_KEY }}
TEST_USER_PRIVATE_KEY: ${{ secrets.TEST_USER_PRIVATE_KEY }}

jobs:
check:
name: Run tests and format checks
runs-on: ubuntu-latest

steps:
- name: Checkout PR head
- name: Checkout
uses: actions/checkout@v4

- name: Fetch base commit
run: |
git fetch origin ${{ github.event.pull_request.base.sha }} --depth=1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Download package artifacts
uses: actions/download-artifact@v3

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm

- name: Run Tests - Unit
run: |
Expand Down
101 changes: 0 additions & 101 deletions .github/workflows/ci.yml

This file was deleted.

16 changes: 4 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,16 @@ on:

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
NODE_VERSION: '22'

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Checkout
uses: actions/checkout@v4

- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm

- name: Create Release Pull Request
uses: changesets/action@v1
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Geist Dapp Kit

on:
pull_request:
branches:
- 'draft'
- 'main'
push:
branches:
- 'draft'
- 'main'
paths:
- 'apps/storybook/**'
- 'pnpm-*.yaml'

env:
TEST_EAS_PRIVATE_KEY: ${{ secrets.TEST_EAS_PRIVATE_KEY }}
TEST_USER_PRIVATE_KEY: ${{ secrets.TEST_USER_PRIVATE_KEY }}
LIGHTHOUSE_API_KEY: ${{ secrets.LIGHTHOUSE_API_KEY }}

jobs:
build-storybook:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm

- name: Build app
run: pnpm --filter storybook build

- name: Upload storybook build
uses: actions/upload-artifact@v4
with:
name: storybook-build
path: apps/storybook/storybook-static

# smoke test, disabled for now
# - name: Build gql
# run: pnpm --filter graphql build:gql

deploy-storybook:
needs: [build-storybook]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm.yml

- name: Download storybook build
uses: actions/download-artifact@v4
with:
name: storybook-build
path: apps/storybook/storybook-static

- name: Deploy app
env:
FLEEK_TOKEN: ${{ secrets.FLEEK_TOKEN }}
FLEEK_PROJECT_ID: ${{ secrets.FLEEK_PROJECT_ID }}
run: pnpm --dir apps/storybook deploy:fleek

0 comments on commit bbdbbae

Please sign in to comment.