diff --git a/content/actions/guides/building-and-testing-nodejs.md b/content/actions/guides/building-and-testing-nodejs.md index 00687c244f..b9468163cb 100644 --- a/content/actions/guides/building-and-testing-nodejs.md +++ b/content/actions/guides/building-and-testing-nodejs.md @@ -92,7 +92,7 @@ strategy: steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} ``` @@ -122,7 +122,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12.x' - run: npm ci @@ -150,7 +150,7 @@ This example installs the dependencies defined in the *package.json* file. For m steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12.x' - name: Install dependencies @@ -164,7 +164,7 @@ Using `npm ci` installs the versions in the *package-lock.json* or *npm-shrinkwr steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12.x' - name: Install dependencies @@ -180,7 +180,7 @@ This example installs the dependencies defined in the *package.json* file. For m steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12.x' - name: Install dependencies @@ -193,7 +193,7 @@ Alternatively, you can pass `--frozen-lockfile` to install the versions in the * steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12.x' - name: Install dependencies @@ -215,7 +215,7 @@ Before installing dependencies, use the `setup-node` action to create the *.npmr steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: always-auth: true node-version: '12.x' @@ -238,29 +238,34 @@ always-auth=true ### Example caching dependencies -When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache dependencies using a unique key, and restore the dependencies when you run future workflows using the `cache` action. For more information, see "Caching dependencies to speed up workflows" and the [`cache` action](https://github.com/marketplace/actions/cache). +When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache and restore the dependencies using the [`setup-node` action](https://github.com/actions/setup-node). -{% raw %} +The following example caches dependencies for npm. ```yaml{:copy} steps: - uses: actions/checkout@v2 -- name: Use Node.js - uses: actions/setup-node@v1 +- uses: actions/setup-node@v2 with: - node-version: '12.x' -- name: Cache Node.js modules - uses: actions/cache@v2 - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- -- name: Install dependencies - run: npm ci + node-version: '14' + cache: 'npm' +- run: npm install +- run: npm test ``` -{% endraw %} + +The following example caches dependencies for Yarn. + +```yaml{:copy} +steps: +- uses: actions/checkout@v2 +- uses: actions/setup-node@v2 + with: + node-version: '14' + cache: 'yarn' +- run: yarn +- run: yarn test +``` + +To cache dependencies, you must have a `package-lock.json` or `yarn.lock` file in the root of the repository. If you need more flexible customization, you can use the [`cache` action](https://github.com/marketplace/actions/cache). For more information, see "Caching dependencies to speed up workflows". ## Building and testing your code @@ -270,7 +275,7 @@ You can use the same commands that you use locally to build and test your code. steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12.x' - run: npm install diff --git a/content/actions/guides/caching-dependencies-to-speed-up-workflows.md b/content/actions/guides/caching-dependencies-to-speed-up-workflows.md index b929150d94..9000798ce5 100644 --- a/content/actions/guides/caching-dependencies-to-speed-up-workflows.md +++ b/content/actions/guides/caching-dependencies-to-speed-up-workflows.md @@ -22,7 +22,11 @@ Workflow runs often reuse the same outputs or downloaded dependencies from one r Jobs on {% data variables.product.prodname_dotcom %}-hosted runners start in a clean virtual environment and must download dependencies each time, causing increased network utilization, longer runtime, and increased cost. To help speed up the time it takes to recreate these files, {% data variables.product.prodname_dotcom %} can cache dependencies you frequently use in workflows. -To cache dependencies for a job, you'll need to use {% data variables.product.prodname_dotcom %}'s `cache` action. The action retrieves a cache identified by a unique key. For more information, see [`actions/cache`](https://github.com/actions/cache). If you are caching Ruby gems, instead consider using the Ruby maintained action, which can cache bundle installs on initiation. For more information, see [`ruby/setup-ruby`](https://github.com/ruby/setup-ruby#caching-bundle-install-automatically). +To cache dependencies for a job, you'll need to use {% data variables.product.prodname_dotcom %}'s `cache` action. The action retrieves a cache identified by a unique key. For more information, see [`actions/cache`](https://github.com/actions/cache). + +If you are caching Ruby gems, instead consider using the Ruby maintained action, which can cache bundle installs on initiation. For more information, see [`ruby/setup-ruby`](https://github.com/ruby/setup-ruby#caching-bundle-install-automatically). + +To cache and restore dependencies for npm or Yarn, you can use the [`actions/setup-node` action](https://github.com/actions/setup-node). {% warning %} diff --git a/content/actions/guides/deploying-to-azure-app-service.md b/content/actions/guides/deploying-to-azure-app-service.md index 594ddce9ef..1dbaaa282d 100644 --- a/content/actions/guides/deploying-to-azure-app-service.md +++ b/content/actions/guides/deploying-to-azure-app-service.md @@ -93,7 +93,7 @@ jobs: - uses: actions/checkout@v2 - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ env.NODE_VERSION }} diff --git a/content/actions/guides/publishing-nodejs-packages.md b/content/actions/guides/publishing-nodejs-packages.md index aa1d25467a..ccd1ba7c33 100644 --- a/content/actions/guides/publishing-nodejs-packages.md +++ b/content/actions/guides/publishing-nodejs-packages.md @@ -219,7 +219,7 @@ jobs: steps: - uses: actions/checkout@v2 # Setup .npmrc file to publish to npm - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: '10.x' registry-url: 'https://registry.npmjs.org' @@ -229,7 +229,7 @@ jobs: env:{% raw %} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # Setup .npmrc file to publish to GitHub Packages - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: registry-url: 'https://npm.pkg.github.com' # Defaults to the user or organization that owns the workflow file diff --git a/content/actions/learn-github-actions/introduction-to-github-actions.md b/content/actions/learn-github-actions/introduction-to-github-actions.md index 0bdb1291a3..4615581d5f 100644 --- a/content/actions/learn-github-actions/introduction-to-github-actions.md +++ b/content/actions/learn-github-actions/introduction-to-github-actions.md @@ -76,7 +76,7 @@ You can create an example workflow in your repository that automatically trigger runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 - run: npm install -g bats - run: bats -v ``` @@ -170,7 +170,7 @@ To help you understand how YAML syntax is used to create a workflow file, this s ```yaml - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 ``` diff --git a/content/actions/learn-github-actions/managing-complex-workflows.md b/content/actions/learn-github-actions/managing-complex-workflows.md index 7018401bff..901744c736 100644 --- a/content/actions/learn-github-actions/managing-complex-workflows.md +++ b/content/actions/learn-github-actions/managing-complex-workflows.md @@ -80,7 +80,7 @@ jobs: matrix: node: [6, 8, 10] steps: - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} ``` diff --git a/content/actions/learn-github-actions/migrating-from-jenkins-to-github-actions.md b/content/actions/learn-github-actions/migrating-from-jenkins-to-github-actions.md index ddf751723b..3acbae7a7f 100644 --- a/content/actions/learn-github-actions/migrating-from-jenkins-to-github-actions.md +++ b/content/actions/learn-github-actions/migrating-from-jenkins-to-github-actions.md @@ -280,8 +280,8 @@ jobs: matrix: os: [macos-latest, ubuntu-latest] steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 with: node-version: 12 - run: npm install -g bats diff --git a/content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md b/content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md index 20d217cb28..d8e48648f0 100644 --- a/content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md +++ b/content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md @@ -410,7 +410,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: '12.x' - run: npm install diff --git a/content/actions/reference/workflow-syntax-for-github-actions.md b/content/actions/reference/workflow-syntax-for-github-actions.md index 32d8127625..fa71fe1df1 100644 --- a/content/actions/reference/workflow-syntax-for-github-actions.md +++ b/content/actions/reference/workflow-syntax-for-github-actions.md @@ -625,9 +625,9 @@ steps: # Reference a specific commit - uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e # Reference the major version of a release - - uses: actions/setup-node@v1 - # Reference a minor version of a release - - uses: actions/setup-node@v1.2 + - uses: actions/setup-node@v2 + # Reference a specific version + - uses: actions/setup-node@v2.2.0 # Reference a branch - uses: actions/setup-node@main ``` diff --git a/content/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access.md b/content/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access.md index b923e18a39..dcf1e2a07e 100644 --- a/content/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access.md +++ b/content/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access.md @@ -57,11 +57,11 @@ You can populate the runner tool cache by running a {% data variables.product.pr mv "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old" mkdir -p "${{ runner.tool_cache }}" - name: Setup Node 10 - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: 10.x - name: Setup Node 12 - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: 12.x - name: Archive tool cache diff --git a/content/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions.md b/content/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions.md index d186828fde..bf1799fbe9 100644 --- a/content/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions.md +++ b/content/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions.md @@ -123,7 +123,7 @@ jobs: steps: {% raw %} - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }}{% endraw %} - uses: actions/download-artifact@main @@ -251,7 +251,7 @@ run-npm-test: steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - uses: actions/download-artifact@main diff --git a/content/packages/quickstart.md b/content/packages/quickstart.md index fbc821ca04..110128b803 100644 --- a/content/packages/quickstart.md +++ b/content/packages/quickstart.md @@ -63,7 +63,7 @@ In this guide, you'll create a {% data variables.product.prodname_actions %} wor runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: 12 - run: npm ci @@ -77,7 +77,7 @@ In this guide, you'll create a {% data variables.product.prodname_actions %} wor contents: read{% endif %} steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: 12 registry-url: {% ifversion ghae %}https://npm.YOUR-HOSTNAME.com/{% else %}https://npm.pkg.github.com/{% endif %}