简体   繁体   中英

Github Action use environment variable as port

How can I use the global environment variable (that I set at the top of the file) as my port number in Github Action (.yml config file)? Is this possible?

I have tried

env: 
   APP_PORT: 3306

   ......
   services: 
     mysql:
   ....
       ports:
       - ${{ env.APP_PORT }}

What you are trying to do is not possible, as services are defined below a job and not below a step:

You can use the env context in the value of any key in a step except for the id and uses keys.

source: https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#env-context )

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