How to read a value from env file to decide whether to execute GitLab CI stage?

How to read a value from env file to decide whether to execute GitLab CI stage

Posted it already in Stack Overflow. Posting it here too.

  • I have a variable stored into env file :
stages:
  - build
  - execute   

build:
    stage: build
    script:
     - Add-Content properties.env -Value PROD="TRUE"
artifacts:
  reports:
    dotenv: properties.env
tags:
    - windows

Now i wanted to read this value in a stage and then decide whether to execute that stage or not.

I did the following, but it isn’t working:*

execute:
    stage: execute
    rules:
    - if: $PROD == "TRUE"
      when: always
    script:
     - echo "happy"
    tags:
      - windows
    dependencies: 
      - build

Thanks.