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

Add hashFiles to the toolkit #472

Closed
thisismydesign opened this issue May 21, 2020 · 7 comments · Fixed by #830
Closed

Add hashFiles to the toolkit #472

thisismydesign opened this issue May 21, 2020 · 7 comments · Fixed by #830
Labels
enhancement New feature or request

Comments

@thisismydesign
Copy link

Describe the enhancement

I'm writing an action. Would like to call ${{ hashFiles(...) }} and ${{ runner.OS }} and get the result from within the action. Is this possible? I understand I could have these as inputs, however the purpose of my action is to simplify that process.

Code Snippet

Something along these lines:

index.js

const core = require("@actions/core");

async function run() {
  const hash = core.runExpression('hashFiles(...)')
}

run();
@thisismydesign thisismydesign added the enhancement New feature or request label May 21, 2020
@thisismydesign thisismydesign changed the title Evaluate expressions from within an action Evaluate context and expressions from within an action May 21, 2020
@thisismydesign
Copy link
Author

thisismydesign commented May 21, 2020

Related to #430 (github.context only exposes a handful of the context though, not what I'm looking for here).

@ericsciple
Copy link
Contributor

ericsciple commented May 21, 2020

You can use the env var RUNNER_OS

The hashFiles source code is here

@joshmgross @TingluoHuang should we add hashFiles to the toolkit?

@thisismydesign today the runner evaluates all expressions. Currently not consumable from javascript action. You can also set an input's default value using an expression. For example actions/checkout uses an expression to set the default repository input.

@thisismydesign
Copy link
Author

Thanks! Would be great for my use case to have access to hashFiles.

@joshmgross
Copy link
Member

should we add hashFiles to the toolkit?

Absolutely. With @actions/cache now available as an npm package, action authors should have a way to consume hashFiles without requiring user input.

@thisismydesign
Copy link
Author

Awesome, that's exactly my use case :)

@ericsciple ericsciple changed the title Evaluate context and expressions from within an action Add hashFiles to the toolkit May 26, 2020
@ericsciple
Copy link
Contributor

Updated the title.

@thisismydesign as a workaround you can copy the relevant source code from the link i pasted above. It's just that one file, the only dependency is @actions/glob and all other dependencies are from provided by nodejs.

@eine
Copy link

eine commented Jun 4, 2020

Since I'm writing a JS Action, I'm using folder-hash instead of copying hashFiles.ts. Nonetheless, I'd prefer to have the function available in this toolkit.

Ref msys2/setup-msys2#23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants