I would like to upload .env file to a build in Github Actions. Is there any way I can do it?

1 Answer 1


It would be easier to store secrets in either secrets or specific environments in the repo:


You can then access the secrets directly or generate an .env file when the GitHub actions runs.

In the workflow file access secrets with ${{ secrets.TOKEN }} or generate an .env file and save secrets in there:

- name: do some stuff
        run: |
          touch .env
          echo TOKEN='${{ secrets.TOKEN }}' >> .env

If using environments to store secrets, don't forget to declare which environment is being used by that job! (documentation)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.