Bitbucket Pipeline deploys to old Heroku app even after updating HEROKU_APP_NAME

I’m deploying a Node.js app using Bitbucket Pipelines to Heroku. Here’s the situation:

The old Heroku app (with a different name) was deleted in September 2024

That old app used a custom domain: http://dev.lightningrentals.com.au

Recently, I created a new Heroku app with the name crm-lr

in my code ,y pipleline

image: node:18

pipelines:
  branches:
    dev:
      - step:
          name: Build Application - (Dev)
          script:
            - cd backend
            - npm install
            - npm run build

      - step:
          name: Create Artifact (Dev)
          script:
            - cd backend
            - git archive --format=tar.gz dev -o application.tar.gz
          artifacts:
            - backend/application.tar.gz

      - step:
          name: Deploy to Heroku (Dev)
          deployment: Staging
          script:
            - pipe: atlassian/heroku-deploy:2.3.0
              variables:
                HEROKU_API_KEY: $HEROKU_API_KEY
                HEROKU_APP_NAME: $HEROKU_APP_NAME
                ZIP_FILE: backend/application.tar.gz
                WAIT: "true"
          caches:
            - node

In Bitbucket → Repository Variables, I’ve added:

HEROKU_API_KEY = [valid key from Heroku account]
HEROKU_APP_NAME = crm-lr

When I push to the dev branch:

The pipeline succeeds

The deployment goes through, but the app is still accessible via the old custom domain (http://dev.lightningrentals.com.au), which was previously mapped to the old (deleted) Heroku account on same email

The newly created app shows up in the Heroku dashboard with name crm-lr, and its Heroku URL is:

https://crm-lr-c6e51a6eb746.herokuapp.com/

though i have updated the repo variables and i am expecting it to deploy on my new app but somehow it is getting uploaded on old app

is there something that i am missing?

Steps to Associate Your Custom Domain with the New Heroku App

  1. Verify Domain Ownership:
  • Heroku requires domain ownership verification before associating a custom domain.
  • Use the [Heroku Domain Release Tool]
    • Add a DNS TXT record to your domain’s DNS settings as instructed by the tool.
    • Once verified, the tool will release the domain from the old app.
  1. Add the Domain to the New Heroku App:
heroku domains:add dev.lightningrentals.com.au -a crm-lr
  • This command associates your custom domain with the new app.
  1. Update DNS Settings:
  • Heroku provides a DNS target for your custom domain.
  • Update your domain’s DNS settings to point to this target:
    • Set a CNAME record for www.dev.lightningrentals.com.au to the provided DNS target.
    • For the root domain (dev.lightningrentals.com.au), set an ALIAS or ANAME record to the same target.
  1. Deploy Your Application:
  • Ensure your Bitbucket Pipeline is correctly configured to deploy to the new Heroku app (crm-lr).
  • Your pipeline script seems correct, but double-check that the HEROKU_APP_NAME variable is set to crm-lr.[devcenter.heroku.com+1help.heroku.com+1]
  1. Test the Domain:
  • After DNS propagation (which can take up to 48 hours), visit http://dev.lightningrentals.com.au to confirm it’s pointing to the new app.

Additional Notes

  • Subdomain Reuse Mitigation: Heroku has implemented measures to prevent subdomain takeovers. This means that even if the old app was deleted, its subdomain (dev.lightningrentals.com.au) might still be reserved and not immediately available for reuse. The Domain Release Tool helps in such cases by verifying ownership before releasing the domain. [blog.heroku.com+1devcenter.heroku.com+1][help.heroku.com+1stackoverflow.com+1]
  • Domain Release Tool: If you encounter issues with the Domain Release Tool, consider contacting Heroku Support directly. They can assist in releasing the domain from the old app.