question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there any possibility to use file as a script?

See original GitHub issue

Maybe using cat file or something? If no, is it possible to add?

Because it is not that easy to write normal js code inside yaml.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jclemcommented, May 18, 2020

The more I think about it, the less I’m convinced that adding this is necessary. If you want to run a file instead of a plain script, it can be done this way:

uses: actions/github-script@v0.9.0
  with:
    script: |
      const path = require('path')
      return require(path.resolve('my-script.js'))({context})

And then, in your file:

module.exports = ({context}) => {
  return context.payload.client_payload.value
}

It’s also safe to use a module exporting an async function in this way as long as you await it in the inline script.

0reactions
sr-apotapovcommented, Apr 6, 2021

While it’s not quite as simple on the user-side as adding a file as an input to the Action, it has the benefit of:

  • Letting the external file be a testable module
  • Keeping this action focused on its goal of enabling quick one-off actions contained entirely in the workflow file itself

@jclem Can you please explain how exactly can people use it? For example I’m trying to use {{secret.NAME}} and {{steps.NAME.outputs.stdout}} context. What should I pass exactly? in yaml and how should I change my JS code?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it safe to open a file that is being written by a running script?
In conclusion, there are possible problems that depend on the program you are using for viewing the file. And there are possible problems ......
Read more >
Is it possible to execute a script stored within a .jpeg file?
Yes, it is possible. I've personally created media files that can run JS when included as the src of a <script> tag. My...
Read more >
How Can I Automatically Run a Script Any Time a File is ...
Hey, WM. Yes, this is possible, thanks to the magic of WMI events, which allow you to write a script to monitor for...
Read more >
Writing Scripts and Working with Data
If you start an editor from the shell, it will (probably) use your current working directory as its default location.
Read more >
Is it possible to script what applications should open certain ...
As far as I know, all file associations are defined on the launchservices.secure.plist file. For macOS Mojave/Catalina this file is located ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found