Skip to content

Commit

Permalink
feat(yarn2-install): allow using no lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Jan 19, 2023
1 parent 278fef9 commit 96ad91b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ For use with Yarn 1.

#### yarn2-install

For use with Yarn 2 (berry).
For use with Yarn 2 (berry). If your project does not use a lockfile, pass `no-lockfile: true`.

[Source](yarn2-install/action.yml)

Expand All @@ -168,6 +168,7 @@ For use with Yarn 2 (berry).
with:
node-version: 18
yarn-args: --immutable --immutable-cache
no-lockfile: true
```

##### Inputs
Expand All @@ -176,6 +177,7 @@ For use with Yarn 2 (berry).
|----------|----------------|------------------------------------|---------------------------------|---------|
| No | `node-version` | The Node.js version to use | `18` | `18` |
| No | `yarn-args` | Arguments to use with yarn install | `--immutable --immutable-cache` | ` ` |
| No | `no-lockfile` | Do not look for yarn.lock | `true` | `false` |

#### pnpm-install

Expand Down
17 changes: 16 additions & 1 deletion yarn2-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ inputs:
default: ''
required: false

no-lockfile:
description: 'Do not look for yarn.lock'
default: 'false'
required: false

runs:
using: composite
steps:
Expand All @@ -24,11 +29,21 @@ runs:
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
shell: bash

- name: 'Calculate hash'
id: calculate-hash
shell: bash
run: |
if [ "${{ inputs.no-lockfile }}" = "true" ]; then
echo "hash=${{ hashFiles('.yarnrc.yml') }}" >> $GITHUB_OUTPUT
else
echo "hash=${{ hashFiles('.yarnrc.yml', '**/yarn.lock') }}" >> $GITHUB_OUTPUT
fi
- name: 'Restore yarn cache'
uses: actions/cache@v3
with:
path: ${{ steps.find-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn2-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }}
key: ${{ runner.os }}-yarn2-${{ steps.calculate-hash.outputs.hash }}
restore-keys: |
${{ runner.os }}-yarn2-
Expand Down

0 comments on commit 96ad91b

Please sign in to comment.