简体   繁体   中英

how to use GitHub environment variable in Actions?

I added environment variables ( NODE_ENV ) in my ' dev ' GitHub Environment .
How can I use it in my Action for my self-hosted runner on AWS?

GitHub

Now, I tried in this way:

- name: start pm2 service
      env:
        NODE_ENV: ${{ secrets.NODE_ENV }}
      run: NODE_ENV=$NODE_ENV pm2 start ./bin/www --name 'backend'

But I can't get the env on the AWS, my app shows nothing.

Try and and use the official example

steps:
  - shell: bash
    env:
      NODE_ENV: ${{ secrets.NODE_ENV }}
    run: |
      echo "NODE=ENV='$NODE_ENV'"
      pm2 start ./bin/www --name 'backend'

Since NODE_ENV is exported, you might not need to prefix pm2 with NODE_ENV=$NODE_ENV .

However, since the value is still empty, that would confirm the " External Configuration/Secret Sources " is not fully supported yet for an AWS App Runner, assuming it is used for a Github self-hosted runner execution.
That differs from the fact App Runners support GitHub Actions since Nov. 2021 .

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