Skip to content

Commit

Permalink
fix(monorepo): Update the setup action to correctly generate cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpj committed Sep 13, 2024
1 parent 4965637 commit 97cb697
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 13 deletions.
74 changes: 62 additions & 12 deletions .github/actions/setup-workspace/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,80 @@ inputs:
runs:
using: "composite"
steps:
- name: Check pnpm version
shell: bash
id: pnpm
run: |
PNPM_VERSION=${PNPM_VERSION:-7.30.5}
PKG_JSON=$(cat package.json | jq -r '.packageManager' | awk -F@ '{print $2}')
if [ ! -z $PKG_JSON ]; then
PNPM_VERSION=$PKG_JSON
fi
if [ ! -z pnpm ]; then
PNPM_VERSION=9.10.0
fi
echo "Using PNPM version $PNPM_VERSION"
echo "version=$PNPM_VERSION" >> $GITHUB_OUTPUT
- name: Setup PNPM
id: pnpm_setup
uses: pnpm/[email protected]
with:
version: ${{ steps.pnpm.outputs.version }}
run_install: false
package_json_file: ./package.json

- name: Restore cached npm dependencies
id: cache-dependencies-restore
uses: actions/cache/restore@v4
with:
path: |
node_modules
~/.cache/Cypress # needed for the Cypress binary
key: "dependencies-${{ hashFiles('pnpm-lock.yaml') }}"

- name: Set up npm registry
uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version-file: .github/.nvmrc
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- uses: pnpm/[email protected]
id: pnpm-install
with:
version: 8.10.2
version: 9.10.0

- name: Get pnpm store directory
shell: bash
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org
node-version-file: .github/.nvmrc
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: setup pnpm config registry
run: pnpm config set registry https://registry.npmjs.org
- name: Install pnpm package manager
run: pnpm install --no-frozen-lockfile
shell: bash

- name: setup pnpm config registry
run: pnpm install --no-frozen-lockfile
- name: Setup pnpm config registry
run: pnpm config set registry https://registry.npmjs.org
shell: bash

- name: Cache npm dependencies
id: cache-dependencies-save
uses: actions/cache/save@v4
with:
path: |
node_modules
~/.cache/Cypress # needed for the Cypress binary
~/.cache/
key: ${{ steps.cache-dependencies-restore.outputs.cache-primary-key }}

- name: Configure git
run: |
git config user.name "Stormie-Bot"
git config user.email "[email protected]"
git config lfs.allowincompletepush true
git config --global init.defaultBranch main
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
uses: storm-software/action-setup@main
with:
packageManager: pnpm
packageManagerVersion: 9.6.0
packageManagerVersion: 9.10.0
stormBot: Stormie-Bot
stormBotGitHubToken: ${{ secrets.STORM_BOT_GITHUB_TOKEN }}

Expand Down

0 comments on commit 97cb697

Please sign in to comment.