'Bitbucket pipeline script didn't change the file when pushing to server on Heroku

I have this file for pipelines configuration bitbucket-pipelines.yml

# This script depends on two environment variables to be set in Bitbucket Pipelines
# 1. $HEROKU_API_KEY - Local environment var that contains your Heroku account's API key
# 2. $HEROKU_STAGING - Local environment var that contains your staging app name in Heroku
# 3. $HEROKU_PRODUCTION - Local environment var that contains your production app name in Heroku

 image: node:14

 # Doing a full clone to be able to push back to Heroku.
 clone:
   depth: full

 pipelines:
   branches:
     # When code is pushed to the staging branch it is deployed automatically to the staging environment.
     staging:
       - step:
           name: "Instalasi Server"
           caches:
            - node
           script:
            - npm install
            - chmod +x install.sh
            - ./install.sh
            - cat .env
            - git push -f https://heroku:[email protected]/$HEROKU_STAGING.git staging:master

I tried to copy .env.bitbucket to .env files, included in install.sh.

install.sh

apt-get update && apt-get install nano
mv ./.env.bitbucket ./.env

structur folder

enter image description here

.env.bitbucket

PORT=3500
NODE_ENV=development
DEBUG=testrolling:*
DB_HOST=<host name>
DB_PORT=5432
DB_DATABASE=<database name>
DB_USERNAME=<database username>
DB_PASSWORD=<database password>
JWT_AUTH=<auth name>
JWT_EXPIRE=10m

.env

PORT=3500
NODE_ENV=development
DEBUG=testrolling:*
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=test_rolling
DB_USERNAME=postgres
DB_PASSWORD=
JWT_AUTH=test_rolling_glory
JWT_EXPIRE=10m

I tried to replace .env files with .env.bitbucket, as you can see in this image below its working just fine. i tried to run cat .env and seen the env has changed, just like the .env.bitbucket.

enter image description here

But when i tried to running it on heroku, the .env still using the old ones. just like shown below.

enter image description here

How to fix the .env files that i push to heroku apps through bitbucket pipeline used the new .env ?

https://www.zionandzion.com/setting-up-continuous-deployment-with-bitbucket-and-heroku/



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source