<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>

CC BY-SA 4.0
2022-12-27T17:42:48.160Z
2022-12-27T17:44:00.240Z
2022-12-27T17:44:00.240Z
Terry Bonds
<p>I would like to upload .env file to a build in Github Actions. Is there any way I can do it?</p>

<github><builds><github-actions><npm>
How to upload a file as user input in Github Actions workflow?
Nitesh B.
# 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)


---

