Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda