Answers: <p>It would be easier to store secrets in either secrets or specific environments in the repo:</p>
  <pre><code>Secrets:
  https://github.com/**account_name**/**repo_name**/settings/secrets/actions
  </code></pre>
  <pre><code>Environments:
  https://github.com/**account_name**/**repo_name**/settings/environments
  </code></pre>
  <p>You can then access the secrets directly or generate an .env file when the GitHub actions runs.</p>
  <p>In the workflow file access secrets with <code>${{ secrets.TOKEN }}</code> or generate an .env file and save secrets in there:</p>
  <pre><code>- name: do some stuff
          run: |
            touch .env
            echo TOKEN='${{ secrets.TOKEN }}' &gt;&gt; .env
            ...etc
  </code></pre>
  <p>If using environments to store secrets, don't forget to declare which environment is being used by that job! (<a href="https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#env" rel="nofollow noreferrer">documentation</a>)</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-12-27T17:42:48.160Z
Answers: 2022-12-27T17:44:00.240Z
Answers: 2022-12-27T17:44:00.240Z
Answers: Terry Bonds
Body: <p>I would like to upload .env file to a build in Github Actions. Is there any way I can do it?</p>
  
Tags: <github><builds><github-actions><npm>
Title: How to upload a file as user input in Github Actions workflow?
UserDisplayName: Nitesh B.
ThreadText: # How to upload a file as user input in Github Actions workflow?
  
  (Asked by: username_0 on 2022-09-05)
  
  I would like to upload .env file to a build in Github Actions. Is there any way I can do it?
  
  **Tags:** github, builds, github-actions, npm
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-12-27. Score: 1
  
  It would be easier to store secrets in either secrets or specific environments in the repo:
  
  ```
  Secrets:
  https://github.com/**account_name**/**repo_name**/settings/secrets/actions
  
  ```
  
  ```
  Environments:
  https://github.com/**account_name**/**repo_name**/settings/environments
  
  ```
  
  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
            ...etc
  
  ```
  
  If using environments to store secrets, don't forget to declare which environment is being used by that job! ([documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#env))
  
  
  ---
  
  