Platform.sh is now Upsun. Click here to learn more
Upsun Fixed User Documentation

Change hooks in different environments

Try Upsun for 15 days
After that, enjoy the same, game-changing Upsun features for less with the First Project Incentive!¹ A monthly $19 perk!
Activate your 15-day trial
¹Terms and conditions apply

You might have certain commands you want to run only in certain environments. For example enabling detailed logging in preview environments or purging your CDN cache for production environments.

The deploy and post_deploy hooks can access all runtime environment variables. Use this to vary those hooks based on the environment.

Check the PLATFORM_ENVIRONMENT_TYPE variable to see if it’s in a production environment:

.platform.app.yaml
hooks:
  deploy: |
    if [ "$PLATFORM_ENVIRONMENT_TYPE" = production ]; then
      # Run commands only when deploying to production
    else
      # Run commands only when deploying to development or staging environments
    fi
    # Commands to run regardless of the environment