github-action icon indicating copy to clipboard operation
github-action copied to clipboard

DOTENV cannot find .env file

Open teamzz111 opened this issue 4 years ago • 14 comments

Hi guys, assuming that

  env:
    SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
    # or if using AWS creds directly
    # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
    # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

Serverless said: DOTENV: Could not find .env file.

Is necesary to create .env in environment of actions?

teamzz111 avatar Aug 08 '20 21:08 teamzz111

Secrets are stored in repo Settings -> Secrets, so a secret with SERVERLESS_ACCESS_KEY must be created in the repo to use this action.

DavideViolante avatar Sep 04 '20 14:09 DavideViolante

I've setted secrets, but error persists.

image

teamzz111 avatar Sep 05 '20 06:09 teamzz111

@teamzz111 are you using serverless-dotenv-plugin?

mlg87 avatar Nov 28 '20 20:11 mlg87

Yes

teamzz111 avatar Nov 28 '20 20:11 teamzz111

@teamzz111 remove that from your plugins and it will work. that plugin is attempting to find an .env file (which i assume you havent checked in)

mlg87 avatar Nov 29 '20 03:11 mlg87

i use .env for TENCENT_SECRET_ID & TENCENT_SECRET_KEY, but it still need serverless login

how do I distinguish between AWS and TENCENT Cloud?

zuojianghua avatar Dec 15 '20 02:12 zuojianghua

I use .env vars for databases, keys etc. I really need this file

teamzz111 avatar Dec 15 '20 07:12 teamzz111

@teamzz111 hi, I am facing same issue in github actions. Did you find a solution for this issue?

prateek105 avatar Aug 13 '21 06:08 prateek105

Remove the plugin or remove your env from gitignore.

teamzz111 avatar Aug 13 '21 06:08 teamzz111

I have removed the plugin. Still when I deploy lambda via github actions I can not see any environment variables on aws console. How do i setup the environment variables for the lambda function. I am using this for my gihub actions

prateek105 avatar Aug 13 '21 06:08 prateek105

I'm facing the same issue.

uvinod avatar Mar 30 '23 09:03 uvinod

I ended up not using the action and just installing the serverless npm package globally then using it to deploy:

      - run: pnpm add --global serverless

      - name: 'Deploy'
        run: |
          #
          # auth
          #
          serverless config credentials \
            --provider aws \
            --key ${{ env.AWS_ACCESS_KEY_ID }} \
            --secret ${{ env.AWS_SECRET_ACCESS_KEY }}
          #
          # deploy
          #
          serverless deploy \
            --config serverless.yml \
            --stage ${{ env.STAGE }} \
            --region ${{ env.AWS_REGION }}
        env:
          AWS_REGION: ${{ secrets.AWS_REGION }}
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}

o-az avatar May 04 '23 12:05 o-az

Solution is this https://github.com/marketplace/actions/setup-serverless-environment

Add this to your GitHub actions file to add environment variables then you can use ${env:FACEBOOK_CLIENT_ID} in your serverless.yml file when deploying with serverless

env: FACEBOOK_CLIENT_ID: ${{ secrets.FACEBOOK_CLIENT_ID }} FACEBOOK_SECRET_KEY: ${{ secrets.FACEBOOK_SECRET_KEY }}

sehrish30 avatar May 17 '23 05:05 sehrish30