Before the start of a 10-game homestand Joe Girardi termed “important,” he mentioned the primary thing that had to happen for his club to get on the kind of roll that had been missing this season.

“You win six out of seven, you win 14 out of 17,” Girardi said Friday, “if your starting pitching is consistent.”

Tuesday night made three straight games in which the Yankees’ starting pitching was just that, and the victories have followed. This time it was Nathan Eovaldi, aided by his bullpen and a four-RBI night by Starlin Castro, leading the way in a 7-1 win over the Orioles in front of 31,192 at the Stadium.

The Yankees (47-46) moved above .500 for the first time since June 25 and pulled within 6½ games of the AL East-leading Orioles (53-39). The Yankees, trying to keep the band together in advance of the Aug. 1 trade deadline, have not been two games over .500 since April 12, when they were 4-2.

“We knew coming out of the All-Star break this was a huge homestand for us,” Brian McCann said.

Eovaldi (8-6, 4.93), in his first start since being banished to the bullpen after going 0-4 with a 9.20 ERA in his previous six starts, allowed one run and four hits in 5 1⁄3 innings. Eovaldi, the subject of trade rumors, received a huge assist from Anthony Swarzak, who took over with one out and the bases loaded in the sixth.

The Yankees, led by the starters, have allowed one run or fewer in three straight games. “That’s how you put long streaks together,” Girardi said afterward.

Eovaldi entered the sixth leading 3-0 and having retired seven straight but allowed a one-out double to Joey Rickard that made it 3-1. After walking Manny Machado to load the bases with slugger Mark Trumbo coming up, Girardi called for Swarzak. The righthander induced foul popouts off the bats of Trumbo, who has 28 home runs, and Jonathan Schoop to end the inning.

That was the start of eight straight retired for Swarzak, who came in with a 4.70 ERA in 12 appearances.

“It’s always fun,” Swarzak said of being summoned in a big situation. “That’s why we play this game.”

The Yankees’ bullpen entered the night not having allowed a run in 22 straight innings, and Swarzak and Nick Goody, who pitched a scoreless ninth, extended that by 3 2⁄3.

Castro went 2-for-4, including a homer and a double, and Didi Gregorius went 2-for-3 with a walk and two runs. Chase Headley’s two-run homer in the eighth made it 7-1.

With one out in the first, Jacoby Ellsbury reached on catcher’s interference for the ninth time this season, breaking a tie with Roberto Kelly for an unusual club record. He was erased when Carlos Beltran grounded into a 4-6-3 double play.

The Yankees took the lead for good in the second. Vance Worley (2-1), making his third start of the season and first since April 15, retired the first two batters before walking Gregorius. Castro got ahead 3-and-1, then slammed a dead-straight 88-mph fastball into the second deck in left for his 11th homer and a 2-0 lead.

Ellsbury’s single in the fifth made it 3-0 and, after Swarzak’s escape in the sixth, Castro’s two-run double in the sixth made it 5-1.

“The feeling in this clubhouse right now is really good,” Swarzak said. “Nobody in this room believes we can’t do it.”