Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOTENV cannot find .env file #36

Open
teamzz111 opened this issue Aug 8, 2020 · 14 comments
Open

DOTENV cannot find .env file #36

teamzz111 opened this issue Aug 8, 2020 · 14 comments

Comments

@teamzz111
Copy link

teamzz111 commented Aug 8, 2020

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?

@DavideViolante
Copy link
Contributor

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

@teamzz111
Copy link
Author

I've setted secrets, but error persists.

image

@mlg87
Copy link

mlg87 commented Nov 28, 2020

@teamzz111 are you using serverless-dotenv-plugin?

@teamzz111
Copy link
Author

Yes

@mlg87
Copy link

mlg87 commented Nov 29, 2020

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

@zuojianghua
Copy link

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?

@teamzz111
Copy link
Author

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

@prateek105
Copy link

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

@teamzz111
Copy link
Author

Remove the plugin or remove your env from gitignore.

@prateek105
Copy link

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

@uvinod
Copy link

uvinod commented Mar 30, 2023

I'm facing the same issue.

@o-az
Copy link
Contributor

o-az commented May 4, 2023

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

@sehrish30
Copy link

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

@danielnmai
Copy link

danielnmai commented Aug 8, 2024

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

Link does not work? I'm facing the same problem, even after removing the plugin, it still fails to load the env vars. My deploy script:

name: Deploy NodeJS API to AWS Lambda with Serverless Framework

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [20.x]
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}

      - name: Build code
        run: yarn install

      - name: Transpile JS code
        run: yarn build

      - name: Deploy to AWS
        uses: serverless/[email protected]
        with:
          args: deploy
        env:
          SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants