Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document ways to get resolved versions #524

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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

Expand Down
25 changes: 25 additions & 0 deletions docs/advanced-usage.md
Expand Up @@ -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)"
```