Skip to content

Commit

Permalink
split out node setup and build for reusability
Browse files Browse the repository at this point in the history
  • Loading branch information
ethangardner committed Dec 19, 2024
1 parent 228461a commit 3ca84ae
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 39 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/_performance-budget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,6 @@ jobs:
env:
CI_JOB_NUMBER: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Read node version from `.nvmrc` file
id: nvmrc
shell: bash
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: Install required node.js version
uses: actions/setup-node@v4
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v4
id: pnpm-install
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
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: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

- uses: andresz1/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/_setup-node-and-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Setup Node and Build"

on:
workflow_call:

permissions:
contents: read

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

- name: Read node version from `.nvmrc` file
id: nvmrc
shell: bash
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT

- name: Install required Node.js version
uses: actions/setup-node@v4
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v4
id: pnpm-install
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build
4 changes: 4 additions & 0 deletions .github/workflows/monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ on:
pull_request:

jobs:
setup-and-build:
uses: ./.github/workflows/_setup-node-and-build.yml

performance-budget:
needs: setup-and-build
uses: ./.github/workflows/_performance-budget.yml

0 comments on commit 3ca84ae

Please sign in to comment.