Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda