Refactor CI script to support other envionments