"It just shows the drive of the team," said the 22-year-old Riley, who made his major league debut May 15.. "You never know what's going to happen. It shows a lot about this team."
Freddie Freeman added a two-run homer, his 15th, in a three-run ninth inning that sealed the Braves' third straight win.
Riley sent a slider from Kyle Crick (2-2) over the wall in right field for his ninth home run of the season in the seventh, turning a 5-3 deficit into a one-run lead. Donaldson pushed the lead to 9-5 in the eighth with a 439-foot shot to left-center field for his eighth.
"I just go out and try to execute my pitches," Crick said regarding Riley's homer. "Whatever happens, happens. In that particular 0-1 slider, I think I executed the pitch. Just a better piece of hitting."
Before Donaldson's eighth-inning home run, Freeman hit his 300th major-league double to right field.
"When you sit back and look at it, it just means I've been here a while," Freeman said. "I've had some success and it's pretty cool. It really is."
Dan Winkler (2-1) had one strikeout in a scoreless sixth inning to get the win.
Three Pirates errors partially contributed to five Braves runs. The three on Riley's home run came after left fielder Bryan Reynolds dropped a soft line drive from Nick Markakis with one out in the seventh.
Ronald Acuna Jr. came home for the opening run of the game after stealing third when catcher Elias Diaz threw the ball into left field in the first. Riley cut Pittsburgh's lead to 5-3 in the sixth by scoring on a pinch-hit single from Matt Joyce after reaching on a gaffe by third baseman Kevin Newman.
"I feel good about it," Braves manager Brian Snitker said. "I felt good once we got down that if we could just hold it, throw up some zeroes and give those guys a chance, they'd come back."
Melky Cabrera had two hits and three RBI, batting cleanup for Pittsburgh in place of Josh Bell. He hit a two-run homer to left, giving the Pirates a 2-1 lead with two outs in the bottom of the first and then added an RBI single that made it 5-2 with two outs in the second.
"(Cabrera) watches a lot of video. He hunts pitches," Pirates manager Clint Hurdle said. "If you look tonight, there are three times he fired first pitch, looking for pitches, he goes up and hunts and sometimes they throw what he's hunting. He doesn't miss it very often."
Bell, the National League Player for the Month for May, was given the day off after playing the Pirates' first 58 games this season. He is batting .332 with 18 home runs and 53 RBI, but was 1 for 10 with six strikeouts in his past two games.
Braves starter Max Fried gave up a season-high five runs and nine hits in four innings.
Steven Brault allowed two runs and five hits in four innings for the Pirates.
Braves: C Tyler Flowers replaced Brian McCann behind the plate. Snitker said McCann was not injured and could catch the next three games. Flowers, a right-handed bat, entered the lineup to match up against the lefty-throwing Brault.
Pirates: OF Gregory Polanco did not play after sitting to start Pittsburgh's 4-2 loss to Milwaukee on Sunday before pinch-hitting in the ninth inning. He has two hits and 11 strikeouts in his past 19 at bats.
Braves: RHP Kevin Gausman (2-4, 5.56) will take the mound for the second game of the three-game set. He went just one inning in his last outing, allowing eight runs and eight hits in a 14-4 loss to Washington last Wednesday.
Pirates: RHP Joe Musgrove (3-6, 4.57) has lost six of his past eight decisions. He gave up 11 runs and 21 hits in 11 innings during his past two starts.
More AP baseball: https://apnews.com/MLB and www.twitter.com/AP-Sports
2019 MLB winter meetings rumors, dates, free-agent updates and predictions
From free-agent signings and blockbuster trades to all of the latest hot stove buzz, this is your one-stop shop for all the MLB offseason action.
Ted Simmons, Marvin Miller finally get their due with Hall of Fame election
A Cardinals catching great and a revolutionary union leader get the recognition they've long deserved.
David Ortiz makes first Dominican Republic appearance since shooting
Former Red Sox slugger David Ortiz made his first public appearance in the Dominican Republic on Sunday nearly six months after he was shot in what authorities called a case of mistaken identity.
Union executive Marvin Miller, catcher Ted Simmons elected to Baseball Hall of Fame
Marvin Miller, the union leader who revolutionized baseball by empowering players to negotiate multimillion-dollar contracts, was elected to baseball's Hall of Fame on Sunday along with former Cardinals catcher Ted Simmons.
Source: D-backs, righty Junior Guerra agree to deal
Right-hander Junior Guerra has reached agreement with the Diamondbacks on a one-year contract, a source confirmed to ESPN.
Keon Broxton returns to Brewers after whirlwind year
The Brewers have signed outfielder Keon Broxton after trading him a year ago.