-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Adopted from https://github.com/belgattitude/nextjs-monorepo-example/blob/main/.github/actions/yarn-nm-install/action.yml | ||
|
||
name: 'Monorepo install (yarn)' | ||
description: 'Run yarn install with node_modules linker and cache enabled' | ||
inputs: | ||
cwd: | ||
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" | ||
required: false | ||
default: '.' | ||
cache-prefix: | ||
description: 'Add a specific cache-prefix' | ||
required: false | ||
default: 'default' | ||
|
||
runs: | ||
using: 'composite' | ||
|
||
steps: | ||
- name: ⚙️ Enable Corepack | ||
shell: bash | ||
working-directory: ${{ inputs.cwd }} | ||
run: corepack enable | ||
|
||
- name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT" | ||
id: yarn-config | ||
shell: bash | ||
working-directory: ${{ inputs.cwd }} | ||
env: | ||
YARN_ENABLE_GLOBAL_CACHE: 'false' | ||
run: | | ||
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | ||
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT | ||
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT | ||
echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT | ||
- name: ♻️ Restore yarn cache | ||
uses: actions/cache@v3 | ||
id: yarn-download-cache | ||
with: | ||
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} | ||
key: yarn-download-cache-${{ inputs.cache-prefix }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} | ||
restore-keys: | | ||
yarn-download-cache-${{ inputs.cache-prefix }}- | ||
- name: 📥 Install dependencies | ||
shell: bash | ||
working-directory: ${{ inputs.cwd }} | ||
run: yarn install --immutable --inline-builds | ||
env: | ||
# Overrides/align yarnrc.yml options (v3, v4) for a CI context | ||
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives | ||
YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only) | ||
YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size | ||
YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present | ||
# Other environment variables | ||
HUSKY: '0' # By default do not run HUSKY install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters