Merge pull request #140 from rangle/nx-migrate #52
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
name: Update Main Cache | |
# This workflow is responsible for maintaining an updated cache of node_modules on the 'main' branch. | |
# It's triggered on every push to the 'main' branch. It checks out the code, sets up Node.js, and caches | |
# the node_modules folder, using a key that is specific to the 'main' branch and the hash of the 'package-lock.json' file. | |
# If the 'package-lock.json' file has not changed since the last push to 'main', the existing cache will be reused. | |
# If the 'package-lock.json' file has changed, a new cache will be created. This ensures that the cache is always | |
# up-to-date with the latest dependencies defined in 'package-lock.json'. This cache can then be used by workflows | |
# in pull requests to speed up the build process by reusing the installed dependencies. | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
update-main-cache: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- name: Checkout the codebase | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# For NX caching | |
# For more info see: https://nx.dev/recipes/ci/monorepo-ci-github-actions | |
- uses: nrwl/nx-set-shas@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
# Cache node_modules to speed up future builds | |
- name: Cache node modules | |
id: cache-nodemodules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json', '**/package.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
# Install dependencies to update the cache | |
- name: Install Dependencies | |
run: npm ci |