DenverCoder1 / github-readme-streak-stats

🔥 Stay motivated and show off your contribution streak! 🌟 Display your total contributions, current streak, and longest streak on your GitHub profile README
https://streak-stats.demolab.com
MIT License
4.82k stars 750 forks source link

[ERROR] [Deployment] .env was not found. Check Contributing.md for details. #419

Closed shariqmalik closed 1 year ago

shariqmalik commented 1 year ago

Describe the bug I'm having issue with the deployment on vercel

To Reproduce Steps I followed for deployment:

  1. Sign in to Vercel or create a new account at https://vercel.com/
  2. Clone this repository with git clone https://github.com/DenverCoder1/github-readme-streak-stats.git
  3. You may also fork the repository and clone your fork instead if you intend to make changes
  4. Enter the directory with cd github-readme-streak-stats
  5. Switch branches to the vercel branch with git checkout vercel
  6. Make sure you have the Vercel CLI installed
  7. Run vercel and follow the prompts to link your Vercel account and select a project name
  8. The app will be deployed to .vercel.app
  9. Visit this link to create a new Personal Access Token (no scopes required)
  10. Scroll to the bottom and click "Generate token"
  11. Visit the Vercel dashboard and select your project, then click "Settings", then "Environment Variables".
  12. Add a new variable with the key TOKEN and the value as your token from step 9 and click "Save".

Screenshots Having the following .env related error. image

trinib commented 1 year ago

@shariqmalik was getting this issue as well. What worked for me just rename .env.example to .env , then add in your KEY token in file and save changes. Then vercel should update .env file if linked with repository

FYI make sure your repo is private so token would not be exposed to public

DenverCoder1 commented 1 year ago

Steps 11 and 12 add the token to the app. After you do those steps it should work

Klay4 commented 1 year ago

@shariqmalik was getting this issue as well. What worked for me just rename .env.example to .env , then add in your KEY token in file and save changes. Then vercel should update .env file if linked with repository

FYI make sure your repo is private so token would not be exposed to public

I've created a .env file with the token and then runned vercel but it still doesn't work immagine

I have even added the token to the app immagine

immagine

trinib commented 1 year ago

@shariqmalik was getting this issue as well. What worked for me just rename .env.example to .env , then add in your KEY token in file and save changes. Then vercel should update .env file if linked with repository

FYI make sure your repo is private so token would not be exposed to public

I've created a .env file with the token and then runned vercel but it still doesn't work immagine

I have even added the token to the app immagine

immagine

It looks like your issue is, you are in the repo main branch and not the branch name "vercel"

Klay4 commented 1 year ago

@shariqmalik was getting this issue as well. What worked for me just rename .env.example to .env , then add in your KEY token in file and save changes. Then vercel should update .env file if linked with repository FYI make sure your repo is private so token would not be exposed to public

I've created a .env file with the token and then runned vercel but it still doesn't work immagine I have even added the token to the app immagine immagine

It looks like your issue is, you are in the repo main branch and not the branch name "vercel"

I'm in the vercel branch and I've changed my git branch by running git checkout vercel before running vercel to deploy immagine

trinib commented 1 year ago

I mean edit .env file in vercel branch in the repo that is connected .. it looked like from in the screenshot you did it in main branch. If still not working just make a private repo with vercel branch contents, connect repo in vercel and then rename file(.env.example) and add key token and save

Klay4 commented 1 year ago

I mean edit .env file in vercel branch in the repo that is connected .. it looked like from in the screenshot you did it in main branch. If still not working just make a private repo with vercel branch contents, connect repo in vercel and then rename file(.env.example) and add key token and save

I've just created a new private repo, added the .env with the token in the vercel branch, recreated the project on verce, changed the Production Branch in vercel, added the token even in the vercel panel, but still don't working. .. immagine

immagine

trinib commented 1 year ago

you can create your private repo on main branch with vercel contents. Also i turn off 'Include source files outside of the Root Directory in the Build Step' in vercel settings in general

Klay4 commented 1 year ago

I've alerady turned off "Include source files outside of the Root Directory in the Build Step" but still not working. Now i try to recreate the repo with the only vercel content as main branch but i think that nothing will change...

shariqmalik commented 1 year ago

@trinib I tried but just like @Klay4 still having the same issue.

shariqmalik commented 1 year ago

Let me know if there is anything I'm still missing.

image

image

image

image

shariqmalik commented 1 year ago

@Klay4 Things worked for me.

  1. Cloned or mirror this repository into a new private repository.
  2. Import private repo to vercel.
  3. Added TOKEN in Environment Variables, unchecked Include resource files outside of Root Directory..., and Hit deploy.
  4. After deployment it won't work as the branch is main. To fix it go back to Settings -> Git and change the branch name from main to vercel.
  5. To change the production branch, you must now push a commit. I just added TOKEN to the .env file and commit it. I have no idea why I did this as I already added TOKEN to the environment variables.
  6. The Production branch changed to vercel and it's working now.

Thanks a lot, @trinib & @DenverCoder1

DenverCoder1 commented 1 year ago

I have added to the steps to redeploy the app after setting the environment variable as it seems to be required (https://github.com/DenverCoder1/github-readme-streak-stats/commit/9b0767eada70dd47180e41afe6205eb60755ac08).

Importing a GitHub repo can simplify the steps for those who choose to do it that way, so thanks for sharing that :+1:.

Also, I'd recommend against putting active tokens in a GitHub repo even if it's private. If it's private it's less likely to be an issue, but files in GitHub repos are not a secure way of storing secrets. .env should only be used if running locally or on a dedicated server. If using a service that provides other methods of inputting secrets (such as Heroku or Vercel), the service's recommended method should be used.