Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from chvmvd/add-yarn-pnpm-support
Browse files Browse the repository at this point in the history
Add `yarn` and `pnpm` support
  • Loading branch information
chvmvd authored Apr 1, 2023
2 parents 33aa891 + 0db0bb5 commit c9ecb8d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ The following configuration options are available:
| Name | Description | Required | Default |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------ |
| `type` | The type of your project. (Other settings will be automatically set for the type of the project. Currently only `vite` is supported.) | `true` | |
| `package-manager` | The package manager that will be used to install dependencies. (`npm`, `yarn` or `pnpm`) | `false` | `npm` |
| `rootDir` | The root directory of your project. (Default is the current directory.) | `false` | `.` |
| `folder` | The folder that contains the built files. (If set to `auto`, it will use the default folder for the type of the project.) | `false` | `auto` |
| `pr-preview` | Whether to create a PR preview or not. | `false` | `true` |
Expand Down
29 changes: 26 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
type:
description: Type of the project(Other settings will be automatically set for the type of the project. Currently only `vite` is supported.)
required: true
package-manager:
description: Package manager to use(`npm`, `yarn` or `pnpm`)
required: false
default: npm
rootDir:
description: Root directory of the project(Default is the current directory)
required: false
Expand Down Expand Up @@ -106,22 +110,41 @@ runs:
- name: Checkout
uses: actions/checkout@v3

- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@v2
with:
version: latest

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: latest
cache: npm
cache-dependency-path: ${{ inputs.rootDir }}/package-lock.json
cache: ${{ inputs.package-manager }}
cache-dependency-path: ${{ inputs.rootDir }}/${{ (inputs.package-manager == 'npm') && 'package-lock.json' || (inputs.package-manager == 'yarn') && 'yarn.lock' || (inputs.package-manager == 'pnpm') && 'pnpm-lock.yaml' }}

- name: Install npm packages
if: ${{ inputs.package-manager == 'npm' }}
working-directory: ${{ inputs.rootDir }}
run: npm ci
shell: bash

- name: Install yarn packages
if: ${{ inputs.package-manager == 'yarn' }}
working-directory: ${{ inputs.rootDir }}
run: yarn install --frozen-lockfile
shell: bash

- name: Install pnpm packages
if: ${{ inputs.package-manager == 'pnpm' }}
working-directory: ${{ inputs.rootDir }}
run: pnpm install --frozen-lockfile
shell: bash

- name: Build Vite project
if: ${{ inputs.type == 'vite' }}
working-directory: ${{ inputs.rootDir }}
run: npx vite build --base ${{ steps.base-url.outputs.result }}/
run: ${{ (inputs.package-manager == 'npm') && 'npx' || (inputs.package-manager == 'yarn') && 'yarn' || (inputs.package-manager == 'pnpm') && 'pnpx' }} vite build --base ${{ steps.base-url.outputs.result }}/
shell: bash

- name: Deploy Production to GitHub Pages
Expand Down

0 comments on commit c9ecb8d

Please sign in to comment.