When invoking an action programmatically, it's not possible to specify what ProjectConfiguration the action should use. This may mean the action is not available at all (if defined specifically in a certain Configuration), or may be invoked differently - the active configuration is always used. The only chance is to change the active configuration - which changes the project's view for everyone, not just for the action being invoked.
Likewise setting the active configuration back after action completes is not a good idea, since the config may flip back and forth unexpectedly for the user.
Note: Gradle does not support Configurations atm.