diff --git a/.github/workflows/_performance-budget.yml b/.github/workflows/_performance-budget.yml index 5312f3c2..af74fce9 100644 --- a/.github/workflows/_performance-budget.yml +++ b/.github/workflows/_performance-budget.yml @@ -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/size-limit-action@v1.8.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/_setup-node-and-build.yml b/.github/workflows/_setup-node-and-build.yml new file mode 100644 index 00000000..0ea4be68 --- /dev/null +++ b/.github/workflows/_setup-node-and-build.yml @@ -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 diff --git a/.github/workflows/monitor.yml b/.github/workflows/monitor.yml index df84d51c..4dba5339 100644 --- a/.github/workflows/monitor.yml +++ b/.github/workflows/monitor.yml @@ -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 \ No newline at end of file