From 7e93407e8c80f07ab682984e8407393d5758026e Mon Sep 17 00:00:00 2001 From: Tomachi <8929706+book000@users.noreply.github.com> Date: Wed, 22 Nov 2023 22:47:23 +0900 Subject: [PATCH] feat: pnpm setup step (#148) --- .github/workflows/reusable-docker.yml | 31 ++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reusable-docker.yml b/.github/workflows/reusable-docker.yml index 826fb47..76e51d2 100644 --- a/.github/workflows/reusable-docker.yml +++ b/.github/workflows/reusable-docker.yml @@ -28,9 +28,9 @@ on: type: string default: ${{ github.event.pull_request.head.sha }} version: - description: Next custom version (Not included prefix) - type: string - default: '' + description: Next custom version (Not included prefix) + type: string + default: "" outputs: version: description: Next version @@ -342,8 +342,24 @@ jobs: # マージされていない時には github.event.pull_request.head.sha を使い、マージされた時にはgithub.base_refを使う ref: ${{ inputs.is-merged == true && github.base_ref || inputs.pr-head-sha }} + - name: 📂 Check exists .node-version + id: check-node-version-file + run: | + if [ ! -f ".node-version" ]; then + echo "exists=false" >> $GITHUB_OUTPUT + else + echo "exists=true" >> $GITHUB_OUTPUT + fi + - name: 🏗️ Setup node env uses: actions/setup-node@v4 + if: ${{ steps.check-node-version-file.outputs.exists == 'true' }} + with: + node-version-file: .node-version + + - name: 🏗️ Setup node env + if: ${{ steps.check-node-version-file.outputs.exists == 'false' }} + uses: actions/setup-node@v2 with: node-version: 18 @@ -358,13 +374,18 @@ jobs: echo "package-manager=npm" >> "$GITHUB_OUTPUT" fi + - name: Setup pnpm + uses: pnpm/action-setup@v2 + if: ${{ steps.check-package-manager.outputs.package-manager == 'pnpm' }} + with: + run_install: false - name: 📦 Install dependencies run: | if [ "${{ steps.check-package-manager.outputs.package-manager }}" == "yarn" ]; then - yarn + yarn install --frozen-lockfile elif [ "${{ steps.check-package-manager.outputs.package-manager }}" == "pnpm" ]; then - pnpm install + pnpm install --frozen-lockfile --prefer-frozen-lockfile else npm install fi