From c4acf4c67affdb1e360ef4eaeb338cd2672ee4a2 Mon Sep 17 00:00:00 2001 From: ethangardner Date: Thu, 19 Dec 2024 09:58:04 -0500 Subject: [PATCH] make install and build workflow reusable --- .github/workflows/_node-install-and-build.yml | 49 +++++++++++++++++++ .github/workflows/_performance-budget.yml | 43 ++-------------- 2 files changed, 52 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/_node-install-and-build.yml diff --git a/.github/workflows/_node-install-and-build.yml b/.github/workflows/_node-install-and-build.yml new file mode 100644 index 00000000..d816f505 --- /dev/null +++ b/.github/workflows/_node-install-and-build.yml @@ -0,0 +1,49 @@ +name: Install and Build Workflow + +on: + workflow_call: + +jobs: + install_and_build: + runs-on: ubuntu-latest + 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 \ No newline at end of file diff --git a/.github/workflows/_performance-budget.yml b/.github/workflows/_performance-budget.yml index 5312f3c2..1d61c30e 100644 --- a/.github/workflows/_performance-budget.yml +++ b/.github/workflows/_performance-budget.yml @@ -9,47 +9,10 @@ permissions: jobs: size: runs-on: ubuntu-latest - 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 + steps: + - name: Install and Build + uses: ./.github/workflows/_node-install-and-build.yml - uses: andresz1/size-limit-action@v1.8.0 with: