Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Github Action js file return string to be saved in a variable

I have a js file like this, which should return me a string to use later in the action:

action.js

async function getData(){
 const url = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Meet_Truffle%21.jpg/440px-Meet_Truffle%21.jpg";
 return url;
}

getData().then((url) => {
  return url;
});

I did a similar thing but it doesn't seem to work, can you tell me how I can do it?

Pull.yml

- name: Url
  run: node ./action.js >> $URL

- uses: suisei-cn/actions-download-file@v1
  id: downloadfile
  name: Download the file
  with:
       url: $URL
       target: assets/
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

An option is to attribute the string to a variable before adding it as a ENV variable in the workflow Github Context.

However, to make it work, you can't use directly return url; in the .js file. You will also need console.log(url); to print the url value to the console.

Your workflow would look like this:

- name: Url
  run: |
     URL=$(node ./action.js)
     echo "URL=$URL" >> $GITHUB_ENV

- uses: suisei-cn/actions-download-file@v1
  id: downloadfile
  name: Download the file
  with:
       url: ${{ env.URL }}
       target: assets/

And the action.js file might look like this (I'm not familiar with node):

async function getData(){
 const url = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Meet_Truffle%21.jpg/440px-Meet_Truffle%21.jpg";
 return url;
}

getData().then((url) => {
  console.log(url);
  return url;
});

You can find an example in this workflow run with python and node. The workflow implementation can be found here.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!