From 343ddd3e7aa63e8b8f906507eddba6dc9b200a1f Mon Sep 17 00:00:00 2001
From: Jack Bates <jack@nottheoilrig.com>
Date: Wed, 8 Jun 2022 09:05:51 -0700
Subject: [PATCH] Document ways to get resolved versions

---
 README.md              |  1 +
 docs/advanced-usage.md | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/README.md b/README.md
index 99a9b0e2..abb81f1f 100644
--- a/README.md
+++ b/README.md
@@ -115,6 +115,7 @@ jobs:
 6. [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm)
 7. [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn)
 8. [Using private packages](docs/advanced-usage.md#use-private-packages)
+9. [Resolved Node.js and npm versions](docs/advanced-usage.md#resolved-nodejs-and-npm-versions)
 
 ## License
 
diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md
index 36c1ec8b..81284ae4 100644
--- a/docs/advanced-usage.md
+++ b/docs/advanced-usage.md
@@ -247,3 +247,28 @@ steps:
 # `npm rebuild` will run all those post-install scripts for us.
 - run: npm rebuild && npm run prepare --if-present
 ```
+
+## Resolved Node.js and npm versions
+
+In the context of a command, you can get the resolved Node.js and npm versions directly by using command substitution, e.g.:
+
+```yaml
+- if: always()
+  name: Add summary
+  run: |
+    echo "## Versions
+
+    | Node.js           | npm              |
+    | ----------------- | ---------------- |
+    | $(node --version) | $(npm --version) |" > "$GITHUB_STEP_SUMMARY"
+```
+
+If instead you need them in the context of an [expression](https://docs.github.com/en/actions/learn-github-actions/expressions), you can store them in [output parameters](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter), e.g.:
+
+```yaml
+- id: versions
+  name: Get versions
+  run: |
+    echo "::set-output name=node-version::$(node --version)"
+    echo "::set-output name=npm-version::$(npm --version)"
+```