You can use a script as part of your action..
Save the code as FileName.jsx in the Photoshops preset/scripts folder.
Code:
var doc = activeDocument;
if(doc.width.value>doc.height.value){//Landscape
doAction("Action Name", "Action Set");
}else{//Portrait
doAction("Action Name", "Action Set");
}
Amend the Action Name and Action set to suit.
Now you can create a new action that call this script that will then call the action for the correct orientation.
When recording the action use: Insert Menu Item then File - Scripts and select your script.