Skip to content

Commit

Permalink
feat(nx-cache): add nx cache action
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Nov 8, 2022
1 parent b2efedb commit 6273559
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ This is a collection of reusable composite actions for GitHub Actions workflows.
- [rebase](#rebase)
- [update-tags](#update-tags)
- [compare-branches](#compare-branches)
- [Miscellaneous](#miscellaneous)
- [cache-nx](#cache-nx)
- [Workflows](#workflows)
- [Semantic Release](#semantic-release-workflow)

Expand Down Expand Up @@ -101,6 +103,7 @@ For use with Yarn 1.
node-version: 16
yarn-args: --frozen-lockfile --ignore-scripts
```

##### Inputs

| required | name | description | Example | Default |
Expand Down Expand Up @@ -449,6 +452,30 @@ Check if there are new commits in head that are not in base.
| `commits` | List of commits in head that are not in base | `• fix: fix a bug (3 days ago)` |
| `compare-url` | Link to the compare view of both commits | `https://github.com/myparcelnl/woocommerce/compare/main..develop` |

### Miscellaneous

#### cache-nx

[Source](cache-nx/action.yml)

Save and restore the [Nx](https://nx.dev/) cache. Defaults to using `yarn.lock` for cache busting, use the `lockfile` input to override this.

1. Runs [actions/cache] and caches `./node_modules/.cache/nx`

##### Inputs

| Required | Name | Description | Example | Default |
|----------|------------|----------------------|---------------------|-------------|
| No | `lockfile` | Path to the lockfile | `package-lock.json` | `yarn.lock` |

##### Example

```yaml
- uses: myparcelnl/actions/cache-nx@v2
with:
lockfile: package-lock.json
```

## Workflows

### Semantic Release workflow
Expand Down
19 changes: 19 additions & 0 deletions cache-nx/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Cache Nx 📦'
description: 'Cache Nx build results'

inputs:
lockfile:
description: 'Path to the lockfile'
default: 'yarn.lock'

runs:
using: composite
steps:
- name: 'Cache Nx'
uses: actions/cache@v3
with:
path: node_modules/.cache/nx
key: {{ runner.os }}-cache-nx-${{ hashFiles('${{ inputs.lockfile }}') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-cache-nx-${{ hashFiles('${{ inputs.lockfile }}') }}-
${{ runner.os }}-cache-nx-

0 comments on commit 6273559

Please sign in to comment.