skip to Main Content

I have configured a dev environment with a Firebase secret, but I can’t write it to my .env.local file when running the CI. Only repository-level secrets work.

How can I access my environment secret?

enter image description here

jobs:
  Deploy-Application:
    runs-on: ubuntu-latest

    steps:
        -   name: Checkout code
            uses: actions/checkout@v3

        -   name: Create .env file
            run: |
                cd /tmp/app
                touch .env.local
                echo FIREBASE_DSN=${{ secrets.FIREBASE_DSN }} >> .env.local

2

Answers


  1. Chosen as BEST ANSWER

    I reformulate my need more simply

    I have 3 environments

    • dev
    • staging
    • prod

    Each of these environments has the FIREBASE_DSN secret with a value specific to its environment:

    enter image description here

    enter image description here

    Secrets are linked to an environment so detection should be done automatically, but there is no variable proposed by github to automatically detect the environment, this does not work. Is the only solution to copy my .yaml file 3 times?

     environment: dev  # <-- Here!
    

  2. You have to specify the environment as part of the job:

    jobs:
      Deploy-Application:
        runs-on: ubuntu-latest
        environment: dev  # <-- Here!
        steps:
          # ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search