简体   繁体   中英

Can't pass environment variable from GitHub Actions to nodejs script

To be short I have an Angular app where I have env config. I decided to write a build number directly into the field of that config file.

So I made a script that is being run by Node after checkout and before the actual build step and writes a build number into that file. This is a fragment of my GitHub Actions workflow yml for it:

        run: |
          npm install
          node setbuildnumber.js build=${{ env.GITHUB_ACTION }}
          npm run build-demo

The script works when I test it separately. And it runs in Actions as I see. But after I build and deploy my Angular app, I see my build number is undefined .

Before writing a question, I looked through Stack Overflow topics and only found a variant where it was recommended to write a variable value to file and then read it with Node script. But that solution looks unclean.

I'm sure now that arguments aren't being passed into the node script. So I've written the variable name into the temporary file, read it, written it into the angular environment configs recursively and deleted the file after all. This is the only thing that worked for me practically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM