One theory, which was suggested by Louis Althusser, is that discourse leads to ideology and actions lead to both. He argued that social practices cause us to have the ideologies that we have and discourse is a social practice. So we speak and act without really thinking about them and eventually this leads to a set of ideas or ideologies.
It's really the opposite of what most people argue about discourse an ideology. It is usually thought that discourse emerges from ideology and not the other way around.