3

from my docker-compose file I have to read an env variable. locally, I can read that variable like this: ENV_FILE=.env docker-compose -f docker-compose.dev.prisma.yml up --build but as .env file is in .gitignore, GitHub action can't get that file. how can I read them?

almost same issue in my package.json file. I have need some env variables to be read from npm scripts:

"start:backend": "wait-port $API_HOST:API_PORT && yarn start"

what I have tried is added those variables in secrets of github, but it didn't get those variables. though expect those 2 files, envs are read perfectly from github action.

Ashik
  • 2,888
  • 8
  • 28
  • 53

1 Answers1

7

Try creating your env file manually as a step in your workflow and pass in your repository secrets. Your docker-compose and package.json should be able to read your environment variables:

    - name: create env file
      run: |
        touch .env
        echo VARIABLE=${{ secrets.VARIABLE }} >> .env
kachow6
  • 1,134
  • 12
  • 15