CodexBloom - Programming Q&A Platform

GitHub Actions not deploying to Heroku due to missing environment variables in .env file

👀 Views: 297 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-17
github-actions heroku nodejs JavaScript

I'm upgrading from an older version and I recently switched to I tried several approaches but none seem to work. I'm working with an scenario with deploying my Node.js application to Heroku using GitHub Actions. The workflow runs successfully, but when the app is accessed, it fails to connect to the database and throws an behavior saying `behavior: Database connection failed`. I've ensured my Heroku app has the correct environment variables set, but I'm not sure if they're being passed correctly from GitHub Actions. Here's the relevant part of my GitHub Actions workflow file: ```yaml name: Deploy to Heroku on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '14' - name: Install dependencies run: npm install - name: Build run: npm run build - name: Deploy to Heroku env: HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} DATABASE_URL: ${{ secrets.DATABASE_URL }} run: git push https://git.heroku.com/my-heroku-app.git main ``` I've added the `DATABASE_URL` and `HEROKU_API_KEY` as secrets in my GitHub repository, but every time the deployment happens, it seems like the application is unable to access the database. Is there a way to confirm if the environment variables are set correctly during the GitHub Action run? Additionally, should I be using a `.env` file in my repository or is the secret management in GitHub Actions sufficient? Any help would be appreciated! I'm working on a service that needs to handle this. Thanks in advance! This issue appeared after updating to Javascript 3.11. I'm working in a Windows 11 environment. Any feedback is welcome!